public function ajaxSubmitAction() { $username = Request::getPOST('username'); $password = Request::getPOST('password'); $verify = Request::getPOST('verify'); if (!Regex::match($username, RegexVars::USERNAME)) { $this->renderAjax(1, '用户名格式不正确!'); } // 校验密码格式 if (!Regex::match($password, RegexVars::PASSWORD)) { $this->renderAjax(1, '密码长度为6-20位!'); } // 校验验证码 $code = Session::get('check_code'); if (strtolower($verify) != $code) { $this->renderAjax(1, '验证码错误,请重试!'); } // 过滤用户名 if (false !== strpos(strtolower($username), 'admin')) { $this->renderAjax(1, '用户已经存在!'); } // 校验用户是否存在 $userInfo = UcUserInterface::getByLoginName(array('login_name' => $username)); if (!empty($userInfo)) { $this->renderAjax(1, '用户名已经被占用!'); } // 保存 $data = array('username' => $username, 'password' => $password, 'reg_ip' => Http::getClientIp()); UcUserInterface::save($data); $this->renderAjax(0); }
public function ajaxSubmitAction() { $resetTicket = Request::getPOST('reset-ticket'); $password = Request::getPOST('password'); if (empty($password) || empty($resetTicket)) { $this->renderAjax(1, '参数错误!'); } if (strlen($password) < 6 || strlen($password) > 30) { $this->renderAjax(1, '密码长度为6-30位!'); } $userInfo = UcAuthInterface::getUserInfoByResetTicket(array('reset_ticket' => $resetTicket)); if (empty($userInfo)) { $this->renderAjax(1, '你的操作已经过期,请重新操作!'); } // 修改密码 UcUserInterface::save(array('id' => $userInfo['id'], 'password' => $password)); // 删除reset ticket UcAuthInterface::deleteResetTicket(array('reset_ticket' => $resetTicket)); UcUserInterface::logout(); $this->renderAjax(0); }
public static function save($params) { return UcUserInterface::save($params); }