public function indexAction() { $sessionId = TZ_Request::checkSessionId(); $uid = TZ_Loader::service('SessionManager', 'User')->getUid($sessionId); if (!$uid) { throw new Exception('请先登陆。'); } $verifyCode = TZ_Request::checkVerifyCode(); $userInfo = TZ_Loader::service('User', 'User')->getInfoByUid($uid); if (empty($userInfo) || !is_array($userInfo)) { throw new Exception('请先登陆。'); } //valid $telephone = $userInfo['telephone']; $validStatus = TZ_Loader::service('VerifyCode', 'User')->valid($telephone, $verifyCode); if (!$validStatus) { throw new Exception('验证码错误。'); } //unset TZ_Loader::service('VerifyCode', 'User')->discard($telephone); //更新验证字段 TZ_Loader::service('User', 'User')->validTelphone($telephone); //response TZ_Request::success(array(array('session_id' => $sessionId))); }
public function indexAction() { $telephone = TZ_Request::checkTelephone(); $verifyCode = TZ_Request::checkVerifyCode(); $validStatus = TZ_Loader::service('VerifyCode', 'User')->valid($telephone, $verifyCode); TZ_Request::success(array(array('verified' => $validStatus))); }
public function indexAction() { $telephone = TZ_Request::checkTelephone(); $verifyCode = TZ_Request::checkVerifyCode(); $password = TZ_Request::checkPassword(); //valid $validStatus = TZ_Loader::service('VerifyCode', 'User')->valid($telephone, $verifyCode); if (!$validStatus) { throw new Exception('验证码错误。'); } $resetStatus = TZ_Loader::service('User', 'User')->resetPassword($telephone, $password); if (!$resetStatus) { throw new Exception('重置密码失败。'); } //unset TZ_Loader::service('VerifyCode', 'User')->discard($telephone); TZ_Request::success(); }