Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Visitor page
- * Log in user
- */
- public function loginAction()
- {
- $form = $this->getUserService()->getRegistrationForm();
- if($this->getRequest()->isPost())
- {
- $data = $this->getRequest()->getParams();
- if($form->isValid($data))
- {
- try
- {
- $this->getUserService()->login($form);
- $this->redirect('/home');
- }
- catch(Exception $e)
- {
- switch($e->getMessage())
- {
- case PR_Exception_User::USER_DEACTIVATED:
- $this->view->message = array('class' => 'error','message' => 'Login failed: This user account is no longer active.');
- break;
- case PR_Exception_User::USER_SUSPENDED:
- $this->view->message = array('class' => 'error','message' => 'Login failed: This user account has been suspended.');
- break;
- case PR_Exception_User::USER_UNACTIVATED:
- $url = $this->view->url(array('email' => $form->getElement('email')->getValue()),'user-resend-activation');
- $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.');
- break;
- case PR_Exception_User::WRONG_PASSWORD:
- case PR_Exception_User::USER_NOT_FOUND:
- $url = $this->view->url(array('email' => $form->getElement('email')->getValue()),'user-forgot-pass');
- $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!');
- break;
- default:
- $this->view->message = array('class' => 'error','message' => 'Login failed: '.$e->getMessage());
- break;
- }
- }
- }
- else
- {
- $form->populate($data);
- }
- }
- $this->view->form = $form;
- }
Add Comment
Please, Sign In to add comment