コード例 #1
0
ファイル: LoginController.php プロジェクト: skybird/phalcon
 public function reactiveAction()
 {
     $username = $this->request->get('username');
     if ($this->request->isAjax()) {
         if (!$username) {
             return $this->showErrorMessageAsJson(400, 'ERR_USER_REACTIVE_NO_USERNAME_INPUT');
         }
         $user = new Models\Register();
         try {
             $user->sendVerificationEmail($username);
             return $this->showResponseAsJson('SUCCESS_USER_ACTIVE_MAIL_SENT');
         } catch (\Exception $e) {
             return $this->showExceptionAsJson($e, $user->getMessages());
         }
     } else {
         if (!$username) {
             return $this->redirectHandler($this->getDI()->getConfig()->user->resetFailedRedirectUri);
         }
         $user = new Models\Register();
         try {
             $user->sendVerificationEmail($username);
             $this->flashSession->success('SUCCESS_USER_ACTIVE_MAIL_SENT');
             return $this->redirectHandler($this->getDI()->getConfig()->user->resetSuccessRedirectUri);
         } catch (\Exception $e) {
             $this->showException($e, $user->getMessages());
             return $this->redirectHandler($this->getDI()->getConfig()->user->resetFailedRedirectUri);
         }
     }
 }
コード例 #2
0
ファイル: SessionController.php プロジェクト: skybird/EvaUser
 public function forgotAction()
 {
     if (!$this->request->isPost()) {
         return;
     }
     $email = $this->request->getPost('identify');
     if ($this->request->isAjax() || $this->request->get('ajax')) {
         if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
             return $this->showErrorMessageAsJson(401, 'ERR_EMAIL_FORMAT_NOT_CORRECT');
         }
         $user = new Models\ResetPassword();
         $user->assign(array('email' => $email));
         try {
             $user->requestResetPassword();
             return $this->showResponseAsJson('SUCCESS_USER_RESET_MAIL_SENT');
         } catch (\Exception $e) {
             // 邮箱未激活,直接发送验证邮件
             if ($e->getCode() == 1000) {
                 $registerUser = new Models\Register();
                 $registerUser->sendVerificationEmail($email);
             }
             return $this->showExceptionAsJson($e, $user->getMessages());
         }
     } else {
         if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
             return $this->redirectHandler($this->getDI()->getConfig()->user->resetFailedRedirectUri);
         }
         $user = new Models\ResetPassword();
         $user->assign(array('email' => $email));
         try {
             $user->requestResetPassword();
             $this->flashSession->success('SUCCESS_USER_RESET_MAIL_SENT');
         } catch (\Exception $e) {
             $this->showException($e, $user->getMessages());
             return $this->redirectHandler($this->getDI()->getConfig()->user->resetFailedRedirectUri);
         }
         return $this->redirectHandler($this->getDI()->getConfig()->user->resetSuccessRedirectUri);
     }
 }