示例#1
0
 /**
  * Confirms an e-mail, if the user must change its password then changes it
  */
 public function confirmEmailAction()
 {
     $code = $this->dispatcher->getParam('code');
     $confirmation = EmailConfirmations::findFirstByCode($code);
     if (!$confirmation) {
         return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
     }
     if ($confirmation->confirmed != 'N') {
         return $this->dispatcher->forward(array('controller' => 'session', 'action' => 'login'));
     }
     $confirmation->confirmed = 'Y';
     $confirmation->user->active = 'Y';
     /**
      * Change the confirmation to 'confirmed' and update the user to 'active'
      */
     if (!$confirmation->save()) {
         foreach ($confirmation->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
     }
     /**
      * Identity the user in the application
      */
     $this->auth->authUserById($confirmation->user->id);
     /**
      * Check if the user must change his/her password
      */
     if ($confirmation->user->mustChangePassword == 'Y') {
         $this->flash->success('The email was successfully confirmed. Now you must change your password');
         return $this->dispatcher->forward(array('controller' => 'users', 'action' => 'changePassword'));
     }
     $this->flash->success('The email was successfully confirmed');
     return $this->dispatcher->forward(array('controller' => 'users', 'action' => 'index'));
 }
示例#2
0
文件: Users.php 项目: kjmtrue/blog
 /**
  * Send a confirmation e-mail to the user if the account is not active
  */
 public function afterSave()
 {
     if ($this->active == 'N') {
         $emailConfirmation = new EmailConfirmations();
         $emailConfirmation->usersId = $this->id;
         if ($emailConfirmation->save()) {
             $this->getDI()->getFlash()->notice('A confirmation mail has been sent to ' . $this->email);
         }
     }
 }