Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1.     function login() {
  2.        
  3.         // If they are already logged in
  4.         if($this->isLoggedIn() !== false) {
  5.             $this->postLoginRedirect();
  6.         }
  7.        
  8.         // Initialise the form
  9.         $this->oForm->init('user_login', '', 'post');
  10.        
  11.         // Set form structure
  12.         $this->oForm->setFormStructure($this->oUser->_loginFormStructure);
  13.        
  14.         // If we have submitted out form
  15.         if($this->oForm->isSubmitted()) {
  16.             // Get the form values
  17.             $aSubmitValues  = $this->oForm->getSubmitValues();
  18.            
  19.             // Perform a login and if it details then set an error on the 'email' field.
  20.             if(!($bRet = $this->oUser->login(trim($aSubmitValues['email']), trim($aSubmitValues['password'])))) {
  21.                 $this->oForm->setElementError('email', 'Login Failed. Please check your credentials and try again.');
  22.             }
  23.            
  24.             // If login was successfull then we redirect them to somewhere.
  25.             if($this->oForm->isValidated()) {
  26.                 $this->postLoginRedirect();
  27.             }
  28.         }
  29.        
  30.         // Get our formbuilder rendering information
  31.         $viewValues = array(
  32.             'formBuilder'   => $this->oForm->getRenderInformation()
  33.         );
  34.        
  35.         // Load the login page.
  36.         $this->loadSmarty('user/login', $viewValues);      
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement