예제 #1
0
 /**
  * Account confirmation through the previous sent mail.
  */
 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 = 1;
     /**
      * 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'));
     }
     /**
      * Identify the user in the application
      */
     $this->flash->success('The email was successfully confirmed');
     return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
 }
예제 #2
0
 /**
  * Confirms an e-mail, if the user must change its password then changes it
  */
 public function confirmEmail2Action()
 {
     if ($this->request->isPost()) {
         if ($this->request->getPost()) {
             $this->response->setContentType('application/json');
             $code = $this->request->getPost('code');
             $confirmation = EmailConfirmations::findFirstByCode($code);
             if (!$confirmation) {
                 $data = array('code' => 1, 'status' => 'error', 'msg' => 'invalid code');
             } else {
                 $confirmation->confirmed = 'Y';
                 $confirmation->user->activated = 1;
                 $confirmation->code = 'ffghfghfhf';
                 $confirmation->save();
                 $data = array('code' => 2, 'status' => 'success', 'msg' => 'The email was successfully confirmed. Now you must change your password');
             }
             $this->response->setContent(json_encode($data));
             $this->response->send();
         }
     }
 }