Inheritance: extends TBB_Form
Ejemplo n.º 1
0
 public function processAction()
 {
     $form = new Admin_Form_UserLogin();
     $this->view->success = true;
     if (!$this->getRequest()->isPost()) {
         return $this->_forward('admin/user/login');
     }
     if (!$form->isValid($_POST)) {
         $this->view->success = false;
         $this->view->userLoginForm = $form;
     }
     $values = $form->getValues();
     $authAdapter = new ZFExt_Auth_Adapter_Doctrine('Zfplanet_Model_User', 'name', 'password', 'SHA256');
     $authAdapter->setIdentity($values['name'])->setCredential($values['password']);
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     if (!$result->isValid()) {
         $this->_redirect('/admin/user/login');
         return;
     }
     Zend_Session::regenerateId();
     $this->_redirect('/admin');
 }
Ejemplo n.º 2
0
 public function loginAction()
 {
     $userForm = new Admin_Form_UserLogin();
     $userForm->setMethod('post')->setAction('/admin/users/login');
     if ($this->_request->isPost()) {
         if ($userForm->isValid($_POST)) {
             $userData = $userForm->getValues();
             //////////////////////// Authentication /////////////////////////
             $adapter = new TBB_Auth_Adapter2($userData['username'], $userData['password']);
             $auth = Zend_Auth::getInstance();
             $result = $auth->authenticate($adapter);
             if ($result->getCode() == Zend_Auth_Result::SUCCESS) {
                 // redirect to module customer regardless of what role the user has
                 return $this->_redirect('/admin');
             } else {
                 // when login fails
                 $this->view->loginMessage = "Sorry, you username or password is incorrect.";
             }
             /////////////////////////////////////////////////////////////////
         } else {
             // when POST data is invalid, this case happens when any of fields in form is empty or invalid.
         }
     }
     $this->view->moduleName = $this->_request->getModuleName();
     $this->view->form = $userForm;
 }