public function loginAction() { $form = new Admin_Form_Login(); $form->setAction($this->baseUrl . '/public/index/login'); if ($this->_request->isPost() && $form->isValid($_POST)) { $uri = Digitalus_Filter_Post::get('uri'); $username = Digitalus_Filter_Post::get('adminUsername'); $password = Digitalus_Filter_Post::get('adminPassword'); $auth = new Digitalus_Auth($username, $password); $result = $auth->authenticate(); if (!$result) { $e = new Digitalus_View_Error(); $e->add($this->view->getTranslation('The username or password you entered was not correct.')); } else { $uri = Digitalus_Toolbox_Page::getHomePageName(); $this->_redirect($uri); } } # ---------------------------------------------------------------------------- # $this->page->content = array('label' => 'Auth', 'headline' => $this->view->getTranslation('Authorisation required'), 'content' => $this->view->partial('partials/login.phtml', array('form' => $form))); $this->page->defaultContent = $this->page->content; // load the view Digitalus_Builder::loadPage(null, 'load_view.xml', $this->page, $this->view); // render the page $this->view->page = $this->page; $this->view->layout()->page = $this->page->getParam('xhtml'); $this->renderScript('index/index.phtml'); }
public function loginAction() { $request = $this->getRequest(); $form = new Admin_Form_Login(); $this->view->form = $form; if ($request->isPost()) { if ($form->isValid($request->getPost())) { $Auth = new Base_Auth_Auth(); $params = $request->getParams(); $Auth->doLogout(); $loginStatusEmail = true; $loginStatusUsername = true; $loginStatusEmail = $Auth->doLogin($params, 'email'); if ($loginStatusEmail == false) { $loginStatusUsername = $Auth->doLogin($params, 'username'); } if ($loginStatusEmail == false && $loginStatusUsername == false) { // Invalid credentials $form->setDescription('Invalid credentials provided'); } else { if ($params['rememberMe'] == 1) { $Auth->remeberMe(true, $params); } else { $Auth->forgotMe('rememberMe'); //delete existing cookies as per new requirement } // Valid credentials // We're authenticated! Redirect to the home page $this->_helper->redirector('dashboard', 'index', 'admin'); } } } }
/** * Login action * * if the form has not been submitted this renders the login form * if it has then it validates the data * if it is sound then it runs the Digitalus_Auth_Adapter function * to authorise the request * on success it redirects to the admin home page * * @return void */ public function loginAction() { $form = new Admin_Form_Login(); $form->setAction($this->baseUrl . '/admin/auth/login'); if ($this->_request->isPost() && $form->isValid($_POST)) { $uri = Digitalus_Filter_Post::get('uri'); $username = Digitalus_Filter_Post::get('adminUsername'); $password = Digitalus_Filter_Post::get('adminPassword'); $auth = new Digitalus_Auth($username, $password); $result = $auth->authenticate(); if ($result) { if ($uri == '' || $uri == 'admin/auth/login') { $uri = 'admin'; } $this->_redirect($uri); } else { $e = new Digitalus_View_Error(); $e->add($this->view->getTranslation('The username or password you entered was not correct.')); } $this->view->uri = $uri; } else { $this->view->uri = Digitalus_Uri::get(); } $this->view->form = $form; }
public function indexAction() { $request = $this->getRequest(); $form = new Admin_Form_Login(); if ($request->isPost()) { if ($form->isValid($request->getPost()) && $this->_isAuthentic($form)) { return $this->_helper->redirector('index', 'index'); } } $this->view->form = $form; }
public function indexAction() { // TODO Auto-generated {0}::indexAction() default action $form = new Admin_Form_Login(); $this->view->form = $form; if ($this->_request->isPost()) { if ($form->isValid($_POST)) { //1.Goi ket noi voi Zend Db $db = Zend_Registry::get('connectDB'); //2. Khoi tao Zend Auth $auth = Zend_Auth::getInstance(); //3. Khai bao bang va 2 cot se su dung so sanh trong qua trinh login $authAdapter = new Zend_Auth_Adapter_DbTable($db); $authAdapter->setTableName('nguoi_dung')->setIdentityColumn('ten_dang_nhap')->setCredentialColumn('mat_khau'); //4. Lay gia tri duoc gui qua tu FORM $uname = $form->getValue('Username'); $paswd = md5($form->getValue('Password')); //5. Dua vao so sanh voi du lieu khai bao o muc 3 $authAdapter->setIdentity($uname); $authAdapter->setCredential($paswd); //6. Kiem tra trang thai cua user neu trang_thai = 1 moi duoc login $select = $authAdapter->getDbSelect(); $select->where('trang_thai = 1'); //7. Lay ket qua truy van $result = $auth->authenticate($authAdapter); if ($result->isValid()) { //8. Lay nhung du lieu can thiet trong bang users neu login thanh cong $data = $authAdapter->getResultRowObject(null, array('mat_khau')); //9. Luu nhung du lieu cua member vao session $auth->getStorage()->write($data); //Update lan dang nhap cuoi $user = Khcn_Api::_()->getItem('default_nguoi_dung', $auth->getStorage()->read()->id); $user->lan_dang_nhap_cuoi = date('Y-m-d H:i:s'); $user->save(); $this->_redirect('/admin/index/index'); } else { $this->view->message = 'Tên đăng nhập hoặc mật khẩu không đúng'; } } else { $this->view->form = $form; } } else { $this->view->form = $form; } }
public function indexAction() { $form = new Admin_Form_Login(); $this->view->form = $form; if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData)) { $adapter = new Rph_Auth_Adapter($form->getValue('login'), sha1($form->getValue('senha'))); $result = Zend_Auth::getInstance()->authenticate($adapter); if (Zend_Auth::getInstance()->hasIdentity()) { return $this->_helper->redirector('index', 'index', 'admin'); } else { $this->_helper->FlashMessenger(implode(' ', $result->getMessages())); } } else { $form->populate($formData); } } }
public function loginAction() { $settings = Zend_Registry::get('environmentSettings'); $layoutVersion = $settings->page->layout; # we don't need the admin menu $layout = Zend_Layout::getMvcInstance(); $layout->setLayout('frontend'); $layout->setLayoutPath(APPLICATION_PATH . DIRECTORY_SEPARATOR . 'layouts' . DIRECTORY_SEPARATOR . $layoutVersion); # actually do the login stuff $form = new Admin_Form_Login(); $req = $this->getRequest(); $this->view->form = $form; if ($req->isPost()) { if ($form->isValid($_POST)) { $values = $form->getValues(); if (User_Model_User::login($values['username'], $values['password'])->isValid()) { return $this->_helper->redirector('index', 'index', 'admin'); } } } }
public function loginAction() { $this->_helper->layout()->setLayout("borrower/layout_login"); $oFormLogin = new Admin_Form_Login(); $oFacebook = new Facebook_Facebook(); if (!$this->_oAuth->hasIdentity() && $oFacebook->getUser()) { $oFacebook->destroySession(); } $aPostData = array(); if ($this->_request->isPost()) { $aPostData = $this->_request->getPost(); if ($oFormLogin->isValid($aPostData)) { $sEmailAddress = $oFormLogin->getValue("user_email_address") != "" ? $oFormLogin->getValue("user_email_address") : ""; $sPassword = $oFormLogin->getValue("user_password"); $oResult = $this->_oAuth->auth($sEmailAddress, $sPassword); if ($oResult->isValid()) { $this->_redirect("/admin"); } } } $oFormLogin->populate($aPostData); $this->view->oFormLogin = $oFormLogin; }
public function loginModalAction() { $this->_helper->layout->disableLayout(); $request = $this->getRequest(); $form = new Admin_Form_Login(); $error = 0; if ($request->isPost()) { if ($form->isValid($request->getPost())) { $params = $request->getParams(); $Auth = new Base_Auth_Auth(); $loginStatusEmail = true; $loginStatusUsername = true; $loginStatusEmail = $Auth->doLogin($params, 'email'); if ($loginStatusEmail == false) { $loginStatusUsername = $Auth->doLogin($params, 'username'); } //$loginStatusUsername=$Auth->doLogin($params, 'username'); if ($loginStatusEmail == false && $loginStatusUsername == false) { $error = 1; } else { $error = 0; if ($params['rememberMe'] == 1) { $Auth->remeberMe(true, $params); } else { $Auth->forgotMe('rememberMe'); //delete existing cookies as per new requirement } } } else { $error = 2; } } $result = array("error" => $error); echo Zend_Json::encode($result); exit; }
/** * The default public action - display login form and login * * @return void */ public function indexAction() { $loginForm = new Admin_Form_Login(); $loginForm->setAction($this->baseUrl . '/' . Digitalus_Toolbox_Page::getCurrentPageName(false)); if ($this->_request->isPost() && $loginForm->isValid($_POST)) { $username = Digitalus_Filter_Post::get('adminUsername'); $password = Digitalus_Filter_Post::get('adminPassword'); $auth = new Digitalus_Auth($username, $password); $result = $auth->authenticate(); if (is_null($result)) { $e = new Digitalus_View_Error(); $e->add($this->view->getTranslation('The username or password you entered was not correct.')); # } else { # $this->_redirect(Digitalus_Toolbox_Page::getHomePageName()); } } $this->view->form = $loginForm; }