Guest User

Untitled

a guest
Aug 23rd, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     /**
  3.      *  Visitor page
  4.      *  Log in user
  5.      */
  6.     public function loginAction()
  7.     {
  8.         $form = $this->getUserService()->getRegistrationForm();
  9.  
  10.         if($this->getRequest()->isPost())
  11.         {
  12.             $data = $this->getRequest()->getParams();
  13.             if($form->isValid($data))
  14.             {
  15.                 try
  16.                 {
  17.                     $this->getUserService()->login($form);
  18.                     $this->redirect('/home');
  19.                 }
  20.                 catch(Exception $e)
  21.                 {
  22.                     switch($e->getMessage())
  23.                     {
  24.                         case PR_Exception_User::USER_DEACTIVATED:
  25.                             $this->view->message = array('class' => 'error','message' => 'Login failed: This user account is no longer active.');
  26.                             break;
  27.                         case PR_Exception_User::USER_SUSPENDED:
  28.                             $this->view->message = array('class' => 'error','message' => 'Login failed: This user account has been suspended.');
  29.                             break;
  30.                         case PR_Exception_User::USER_UNACTIVATED:
  31.                             $url = $this->view->url(array('email' => $form->getElement('email')->getValue()),'user-resend-activation');
  32.                             $this->view->message = array('class' => 'error','message' => 'This user account has not been activated, click <a href="'.$url.'">here</a> to resend an account activation email.');
  33.                             break;
  34.                         case PR_Exception_User::WRONG_PASSWORD:
  35.                         case PR_Exception_User::USER_NOT_FOUND:
  36.                             $url = $this->view->url(array('email' => $form->getElement('email')->getValue()),'user-forgot-pass');
  37.                             $this->view->message = array('class' => 'error','message' => 'Login failed: The username or password was incorrect. Forgotten password? Click <a href="'.$url.'">here</a> to reset it!');
  38.                             break;
  39.                         default:
  40.                             $this->view->message = array('class' => 'error','message' => 'Login failed: '.$e->getMessage());
  41.                             break;
  42.                     }
  43.                 }
  44.             }
  45.             else
  46.             {
  47.                 $form->populate($data);
  48.             }
  49.         }
  50.         $this->view->form = $form;
  51.     }
Add Comment
Please, Sign In to add comment