/** * 设置安全问题 */ public function dosetQAction() { list($oldPwd, $question, $answer) = $this->getInput(array('oldPwd', 'question', 'answer'), 'post'); if (!$oldPwd) { $this->showError('USER:pwd.error'); } $userDm = new PwUserInfoDm($this->loginUser->uid); $userDm->setOldPwd($oldPwd); switch ($question) { case -2: //取消安全问题和答案 //取消安全问题和答案 case -3: //无安全问题 $question = $answer = ''; $userDm->setQuestion('', ''); break; case -4: //自定义安全问题 $myquestion = $this->getInput('myquestion', 'post'); if (!$myquestion || !$answer) { $this->showError('USER:login.question.setting'); } $userDm->setQuestion($myquestion, $answer); break; case -1: //不修改安全问题和答案 // $this->showMessage('USER:pwd.change.success', 'profile/password/question'); break; default: if (!$answer) { $this->showError('USER:login.question.setting.answer.require'); } $userDm->setQuestion($question, $answer); break; } /* @var $userService PwUserService */ $userService = Wekit::load('user.srv.PwUserService'); //如果该用户必须设置安全问题 if ($userService->mustSettingSafeQuestion($this->loginUser->uid)) { if (!$question || $question == -1 && !$userService->isSetSafecv()) { $this->showError('USER:user.error.safequestion.need'); } } /* @var $userDs PwUser */ $userDs = Wekit::load('user.PwUser'); if (($result = $userDs->editUser($userDm, PwUser::FETCH_MAIN)) instanceof PwError) { $this->showError($result->getError()); } $this->showMessage('USER:login.question.setting.success', 'profile/password/question'); }
/** * 保存修改密码 * @access public * @return void * @example <pre> /index.php?m=native&c=user&a=doPassWord <br> post: securityKey&oldPwd&newPwd&rePwd </pre> */ public function doPasswordAction() { $this->checkUserSessionValid(); // list($newPwd, $oldPwd, $rePwd) = $this->getInput(array('newPwd', 'oldPwd', 'rePwd'), 'post'); if (!$oldPwd) { $this->showError('USER:pwd.change.oldpwd.require'); } if (!$newPwd) { $this->showError('USER:pwd.change.newpwd.require'); } if ($rePwd != $newPwd) { $this->showError('USER:user.error.-20'); } $this->checkOldPwd($this->uid, $oldPwd); Wind::import('SRC:service.user.dm.PwUserInfoDm'); $userDm = new PwUserInfoDm($this->uid); $userDm->setPassword($newPwd); $userDm->setOldPwd($oldPwd); /* @var $userDs PwUser */ $userDs = Wekit::load('user.PwUser'); if (($result = $userDs->editUser($userDm, PwUser::FETCH_MAIN)) instanceof PwError) { $this->showError($result->getError()); } $this->showMessage('USER:pwd.change.success'); }