/** * 重置密码 */ public function doresetpwdAction() { if ($this->getInput('step', 'post') == 'end') { list($userInfo, $value, $type) = $this->checkState(); list($password, $repassword) = $this->getInput(array('password', 'repassword'), 'post'); if ($password != $repassword) { $this->showError('USER:user.error.-20'); } $userDm = new PwUserInfoDm($userInfo['uid']); $userDm->setUsername($userInfo['username']); $userDm->setPassword($password); $userDm->setQuestion('', ''); /* @var $userDs PwUser */ $userDs = Wekit::load('user.PwUser'); $result = $userDs->editUser($userDm, PwUser::FETCH_MAIN); if ($result instanceof PwError) { $this->showError($result->getError()); } else { //检查找回密码次数及更新 $findPasswordBp = new PwFindPassword($userInfo['username']); $findPasswordBp->success($type); } $this->showMessage('USER:findpwd.success', 'u/login/run?backurl=' . WindUrlHelper::createUrl('bbs/index/run')); } }
/** * 执行设置安全问题 */ public function dosettingAction() { $statu = $this->checkUserInfo(); $code = $this->getInput('code', 'post'); if ($this->_showVerify() && 1 != $this->getInput('v', 'post')) { $veryfy = $this->_getVerifyService(); if (false === $veryfy->checkVerify($code)) { $this->showError('USER:verifycode.error'); } } list($question, $answer) = $this->getInput(array('question', 'answer'), 'post'); if (!$question || !$answer) { $this->showError('USER:login.question.setting'); } if (intval($question) === -4) { $question = $this->getInput('myquestion', 'post'); if (!$question) { $this->showError('USER:login.question.setting'); } } /* @var $userDs PwUser */ $userDs = Wekit::load('user.PwUser'); $userDm = new PwUserInfoDm($this->loginUser->uid); $userDm->setQuestion($question, $answer); if (($result = $userDs->editUser($userDm, PwUser::FETCH_MAIN)) instanceof PwError) { $this->showError($result->getError()); } $this->showMessage('USER:login.question.setting.success', 'u/login/welcome?_statu=' . $statu); }
/** * 获取注册的信息 * * @return PwUserInfoDm */ private function _getUserDm() { list($username, $password, $repassword, $email, $aliww, $qq, $msn, $mobile, $mobileCode, $hometown, $location, $question, $answer, $regreason, $code) = $this->getInput(array('username', 'password', 'repassword', 'email', 'aliww', 'qq', 'msn', 'mobile', 'mobileCode', 'hometown', 'location', 'question', 'answer', 'regreason', 'code'), 'post'); // 验证输入 Wind::import('Wind:utility.WindValidator'); $config = $this->_getRegistConfig(); if (!$username) { $this->showError('USER:user.error.-1', 'u/register/run'); } if (!$password) { $this->showError('USER:pwd.require', 'u/register/run'); } if (!$email) { $this->showError('USER:user.error.-6', 'u/register/run'); } if (!WindValidator::isEmail($email)) { $this->showError('USER:user.error.-7', 'u/register/run'); } foreach ($config['active.field'] as $field) { if (!$this->getInput($field, 'post')) { $this->showError('USER:register.error.require.needField.' . $field, 'u/register/run'); } } if ($config['active.check'] && !$regreason) { $this->showError('USER:register.error.require.regreason', 'u/register/run'); } if ($config['active.phone']) { !PwUserValidator::isMobileValid($mobile) && $this->showError('USER:error.mobile', 'u/register/run'); if (($mobileCheck = Wekit::load('mobile.srv.PwMobileService')->checkVerify($mobile, $mobileCode)) instanceof PwError) { $this->showError($mobileCheck->getError()); } } if ($repassword != $password) { $this->showError('USER:user.error.-20', 'u/register/run'); } if (in_array('register', (array) Wekit::C('verify', 'showverify'))) { $veryfy = Wekit::load("verify.srv.PwCheckVerifyService"); if (false === $veryfy->checkVerify($code)) { $this->showError('USER:verifycode.error', 'u/register/run'); } } Wind::import('SRC:service.user.dm.PwUserInfoDm'); $userDm = new PwUserInfoDm(); $userDm->setUsername($username); $userDm->setPassword($password); $userDm->setEmail($email); $userDm->setRegdate(Pw::getTime()); $userDm->setLastvisit(Pw::getTime()); $userDm->setRegip(Wind::getComponent('request')->getClientIp()); $userDm->setAliww($aliww); $userDm->setQq($qq); $userDm->setMsn($msn); $userDm->setMobile($mobile); $userDm->setMobileCode($mobileCode); $userDm->setQuestion($question, $answer); $userDm->setRegreason($regreason); $areaids = array($hometown, $location); if ($areaids) { $srv = WindidApi::api('area'); $areas = $srv->fetchAreaInfo($areaids); $userDm->setHometown($hometown, isset($areas[$hometown]) ? $areas[$hometown] : ''); $userDm->setLocation($location, isset($areas[$location]) ? $areas[$location] : ''); } return $userDm; }
/** * 编辑用户信息操作 * * @return voido */ public function doEditAction() { $info = $this->checkUser(); Wind::import('SRC:service.user.dm.PwUserInfoDm'); $dm = new PwUserInfoDm($info['uid']); //用户信息 //$dm->setUsername($this->getInput('username', 'post')); list($password, $repassword) = $this->getInput(array('password', 'repassword'), 'post'); if ($password) { if ($password != $repassword) { $this->showError('USER:user.error.-20'); } $dm->setPassword($password); } $dm->setEmail($this->getInput('email', 'post')); list($question, $answer) = $this->getInput(array('question', 'answer'), 'post'); switch ($question) { case '-2': $dm->setQuestion('', ''); break; case '-1': default: break; } $dm->setRegdate(Pw::str2time($this->getInput('regdate', 'post'))); $dm->setRegip($this->getInput('regip', 'post')); $dm->setOnline(intval($this->getInput('online', 'post')) * 3600); //基本资料 $dm->setRealname($this->getInput('realname', 'post')); $dm->setGender($this->getInput('gender', 'post')); $birthday = $this->getInput('birthday', 'post'); if ($birthday) { $bir = explode('-', $birthday); isset($bir[0]) && $dm->setByear($bir[0]); isset($bir[1]) && $dm->setBmonth($bir[1]); isset($bir[2]) && $dm->setBday($bir[2]); } else { $dm->setBday('')->setByear('')->setBmonth(''); } list($hometown, $location) = $this->getInput(array('hometown', 'location'), 'post'); $srv = WindidApi::api('area'); $areas = $srv->fetchAreaInfo(array($hometown, $location)); $dm->setLocation($location, isset($areas[$location]) ? $areas[$location] : ''); $dm->setHometown($hometown, isset($areas[$hometown]) ? $areas[$hometown] : ''); $dm->setHomepage($this->getInput('homepage', 'post')); $dm->setProfile($this->getInput('profile', 'post')); //交易信息 $dm->setAlipay($this->getInput('alipay', 'post')); $dm->setMobile($this->getInput('mobile', 'post')); $dm->setTelphone($this->getInput('telphone', 'post')); $dm->setAddress($this->getInput('address', 'post')); $dm->setZipcode($this->getInput('zipcode', 'post')); //联系信息 $dm->setEmail($this->getInput('email', 'post')); $dm->setAliww($this->getInput('aliww', 'post')); $dm->setQq($this->getInput('qq', 'post')); $dm->setMsn($this->getInput('msn', 'post')); /* @var $pwUser PwUser */ $pwUser = Wekit::load('user.PwUser'); $result = $pwUser->editUser($dm); if ($result instanceof PwError) { $this->showError($result->getError()); } $isFounder = $this->isFounder($info['username']); $this->showMessage($isFounder ? 'USER:founder.update.success' : 'USER:update.success', 'u/manage/edit?uid=' . $info['uid']); }
/** * 设置安全问题 */ public function dosetQAction() { list($oldPwd, $question, $answer) = $this->getInput(array('oldPwd', 'question', 'answer'), 'post'); if (!$oldPwd) { $this->showError('USER:pwd.error'); } $this->checkOldPwd($this->loginUser->uid, $oldPwd); $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->loginUser->reset(); $this->showMessage('USER:login.question.setting.success', 'profile/password/question'); }
/** * 找回密码 * * @access public * @return void */ public function findPwdAction() { $step = $this->getInput('step'); $username = $this->getInput('username'); // Wind::import('SRV:user.srv.PwFindPassword'); $findPasswordBp = new PwFindPassword($username); // switch ($step) { case 1: //返回混淆的email $email = $findPasswordBp->getFuzzyEmail(); $this->setOutput($email, 'data'); $this->showMessage('success'); break; case 2: //通过username&email发送邮件 $email = $this->getInput('email'); /*检查邮箱是否正确*/ if (true !== ($result = $findPasswordBp->checkEmail($email))) { $this->showError($result->getError()); } /*发送重置邮件*/ if (!$findPasswordBp->sendResetEmail(PwFindPassword::createFindPwdIdentify($username, PwFindPassword::WAY_EMAIL, $email))) { $this->showError('USER:findpwd.error.sendemail'); } $this->showMessage('USER:active.sendemail.success'); break; case 3: //_statu 找回密码 $statu = $this->getInput('_statu', 'get'); !$statu && ($statu = $this->getInput('statu', 'post')); if (!$statu) { $this->showError('USER:illegal.request'); } list($username, $way, $value) = PwFindPassword::parserFindPwdIdentify($statu); $userInfo = $this->_getUserDs()->getUserByName($username, PwUser::FETCH_INFO | PwUser::FETCH_MAIN); if ($userInfo[PwFindPassword::getField($way)] != $value) { $this->showError('fail'); } // $code = $this->getInput('code', 'get'); $findPasswordBp = new PwFindPassword($userinfo['username']); if ($way == PwFindPassword::WAY_EMAIL) { if ($findPasswordBp->isOverByMail()) { $this->showError('USER:findpwd.over.limit.email'); } if (($result = $findPasswordBp->checkResetEmail($value, $code)) instanceof PwError) { $this->showError($result->getError()); } } $this->showMessage("USER:findpwd.over.validate.success"); break; case 4: $statu = $this->getInput('_statu', 'get'); !$statu && ($statu = $this->getInput('statu', 'post')); if (!$statu) { $this->showError('USER:illegal.request'); } list($username, $way, $value) = PwFindPassword::parserFindPwdIdentify($statu); $userInfo = $this->_getUserDs()->getUserByName($username, PwUser::FETCH_INFO | PwUser::FETCH_MAIN); if ($userInfo[PwFindPassword::getField($way)] != $value) { $this->showError('fail'); $this->forwardAction('u/findPwd/run', array(), true); } // list($password, $repassword) = $this->getInput(array('password', 'repassword'), 'post'); if ($password != $repassword) { $this->showError('USER:user.error.-20'); } $userDm = new PwUserInfoDm($userInfo['uid']); $userDm->setUsername($userInfo['username']); $userDm->setPassword($password); $userDm->setQuestion('', ''); /* @var $userDs PwUser */ $userDs = Wekit::load('user.PwUser'); $result = $this->_getUserDs()->editUser($userDm, PwUser::FETCH_MAIN); if ($result instanceof PwError) { $this->showError($result->getError()); } else { //检查找回密码次数及更新 $findPasswordBp = new PwFindPassword($userInfo['username']); $findPasswordBp->success($type); } $this->showMessage('USER:findpwd.success'); break; } }