public function loginAction() { $LoginForm = new Application_Form_LoginForm(); $this->view->employee = $LoginForm; $postdata = $this->getRequest()->getPost(); //print_r($postdata);die; if ($postdata) { if ($LoginForm->isValid($postdata)) { $username = $postdata['username']; $password = $postdata['password']; $log = new Service_Employee(); $getlogin = $log->get($username, $password); //print_r($getlogin); die('tested'); if (!empty($getlogin)) { //var_dump($getlogin); exit; $emp_id = $getlogin->getEmpId(); //var_dump($emp_id); exit; // Setting emp_id in Session echo "Login Successfully"; $authNamespace = new Zend_Session_Namespace('assetform'); $authNamespace->username = $username; $authNamespace->emp_id = $emp_id; //$authNamespace->password = "******"; $this->_helper->redirector('asset', 'Asset'); } else { echo "Wrong Entry"; } } } }
public function loginAction() { if (Zend_Auth::getInstance()->hasIdentity()) { $this->_redirect('/'); } $request = $this->getRequest(); $form = new Application_Form_LoginForm(); if ($request->isPost() && $form->isValid($this->_request->getPost())) { $adapter = $this->getAdapter(); $email = $form->getValue('email'); $password = $form->getValue('password'); $adapter->setIdentity($email)->setCredential($password); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($adapter); if ($result->isValid()) { $identity = $adapter->getResultRowObject(); $storage = $auth->getStorage(); $storage->write($identity); $this->_redirect('/'); } else { $this->view->errorMessage = "Username or password is wrong"; } } $this->view->form = $form; }
public function loginAction() { $users = new Application_Model_DbTable_Users(); $form = new Application_Form_LoginForm(); $this->view->form = $form; if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { $data = $form->getValues(); $auth = Zend_Auth::getInstance(); $authAdapter = new Zend_Auth_Adapter_DbTable($users->getAdapter(), 'users'); $authAdapter->setIdentityColumn('username')->setCredentialColumn('password'); $authAdapter->setIdentity($data['username'])->setCredential($data['password']); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $storage = new Zend_Auth_Storage_Session(); $storage->write($authAdapter->getResultRowObject()); $this->_redirect('auth/home'); } else { $this->view->errorMessage = "Invalid username or password. Please try again."; } } } }
public function indexAction() { //$this->_helper->layout()->setLayout('notlogged'); if (Zend_Auth::getInstance()->hasIdentity()) { $this->_redirect('/account/profile'); } $loginform = new Application_Form_LoginForm(); $request = $this->getRequest(); if ($request->isPost()) { if ($loginform->isValid($request->getPost())) { $email = $loginform->getValue('email'); $password = $loginform->getValue('password'); $result = new Application_Model_Base(); $result->authUser($email, $password); if ($result == true) { $this->_redirect('/things'); } else { $errorMessage = "Wrong username or password provided. Please try again."; } } } // $this->view->errorMessage = $errorMessage; $this->view->loginform = $loginform; }