public function logoutAction() { Zend_Session::forgetMe(); $client = Infra_ClientHelper::getClient(); $client->session->end(); Infra_AuthHelper::getAuthInstance()->clearIdentity(); $this->_helper->redirector('index', 'index'); }
/** * Destroys the session of the user currently logged in. * @param boot $cms whether to log out of the cms as well * @return array $response */ public function logout($cms = true) { $cookies = array(); // get the auth singleton, clear the identity and redirect. Zend_Auth::getInstance()->clearIdentity(); Zend_Session::forgetMe(); return array('status' => 'redirect', 'cookies' => $cookies); }
/** * Logs the user off. The identity is removed and the session is cleared. */ public function logoutAction() { Zend_Auth::getInstance()->clearIdentity(); Zend_Session::forgetMe(); unset($this->_defaultNamespace->user); $this->_helper->flashMessenger->addMessage('Sie wurden erfolgreich vom System abgemeldet.'); $this->_helper->redirector('index', 'index'); }
/** * Logout request comes to this action. */ public function logoutAction() { $auth = Zend_Auth::getInstance(); $auth->setStorage(new Zend_Auth_Storage_Session('user')); if ($auth->hasIdentity()) { $auth->clearIdentity(); Zend_Session::forgetMe(); } Zend_Session::destroy(); $this->_redirect('/'); }
/** * Authenticate a user * * @param array $data Matched pair array containing email/password * @return boolean */ public function authenticate($data) { $adapter = $this->getAuthAdapter($data); $auth = $this->getAuth(); $result = $auth->authenticate($adapter); if (!$result->isValid()) { return false; } if ($data['save-login']) { Zend_Session::rememberMe(); } else { Zend_Session::forgetMe(); } $user = $this->_userModel->findByEmail($data['email']); $auth->getStorage()->write($user->toArray()); return true; }
public function proceedAction() { // double check upgrade is necessary in case someone access this action directly if (!$this->_needsUpgrade()) { $this->_redirect(''); return; } $form = new Install_Form_UpgradeLogin(); $formData = $this->_request->getPost(); $form->populate($formData); if (!$form->isValid($formData)) { $appSession = Zend_Registry::get('appSession'); $appSession->loginForm = $form; $this->_forward('index'); return; } $users = new Users_Model_Users(); list($super, $mayor, $minor) = explode('.', $this->_getDbVersion()); $greaterThan2 = $super >= 2; $result = $users->authenticate($this->_request->getPost('username'), $this->_request->getPost('password'), false, $this->view, !$greaterThan2); if (!$result) { $this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid credentials')); $this->_redirect('index'); return; } $user = $users->getUser(); if ($user->role != Users_Model_User::ROLE_ADMIN) { Zend_Auth::getInstance()->clearIdentity(); $this->_helper->FlashMessenger->addMessage($this->view->translate('Invalid credentials')); $this->_redirect('index'); return; } $this->_runUpgrades(true); $upgradedVersion = $this->_runUpgrades(false); $this->_helper->FlashMessenger->addMessage($this->view->translate('Upgrade was successful. You are now on version %s', $upgradedVersion)); $missingConfigs = $this->_checkMissingConfigDirectives(); if ($missingConfigs) { $this->_helper->FlashMessenger->addMessage($this->view->translate('WARNING: there are some new configuration settings. To override their default values (as set in config.default.php) add them to your config.php file. The new settings correspond to the following directives: %s.', implode(', ', $missingConfigs))); } // we need to logout user in case the user table changed Zend_Auth::getInstance()->clearIdentity(); Zend_Session::forgetMe(); $this->_redirect('/'); }
/** * ACL Login * * @param string $email * @param string $password * @return Zend_Auth_Result | boolean */ public static function fastlogin($email, $password, $rememberMe = false) { if (!empty($email) && !empty($password)) { $adapter = new Shineisp_Auth_Adapter_Doctrine(Doctrine_Manager::connection()->getTable("AdminUser"), "email", "password"); $adapter->setCredential($password); $adapter->setIdentity($email); if ($rememberMe) { // remember the session for 604800s = 7 days Zend_Session::rememberMe(604800); } else { // do not remember the session Zend_Session::forgetMe(); } $auth = Zend_Auth::getInstance(); $auth->setStorage(new Zend_Auth_Storage_Session('admin')); return $auth->authenticate($adapter); } else { return false; } }
/** * Login * * @return void */ public function postAction() { // Get params $userName = $this->_request->getParam('userName'); $password = $this->_request->getParam('password'); $rememberMe = $this->_request->getParam('rememberMe'); // Check rememberMe checkbox if (is_null($rememberMe)) { Zend_Session::forgetMe(); } if ($this->getRequest()->isPost() && Kebab_Validation_UserName::isValid($userName) && Kebab_Validation_Password::isValid($password)) { $hasIdentity = Kebab_Authentication::signIn($userName, $password, !is_null($rememberMe)); if ($hasIdentity) { $this->_helper->response(true, 200)->getResponse(); } else { $this->_helper->response()->addNotification(Kebab_Notification::ERR, 'Please check your user name and password!')->getResponse(); } } else { $this->_helper->response()->getResponse(); } }
public function preDispatch(Zend_Controller_Request_Abstract $request) { if (!in_array($request->getModuleName(), $this->modules)) { return; } $authInstance = Zend_Auth::getInstance(); //SAML login: if (isset($_SERVER['eppn'])) { //lookup user with this eduPersonPrincipalName: $model = new OpenSKOS_Db_Table_Users(); $user = $model->fetchRow($model->select()->where('eppn=?', $_SERVER['eppn'])); if (null !== $user) { if ($user->active != 'Y') { Zend_Auth::getInstance()->clearIdentity(); Zend_Session::forgetMe(); Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->setNamespace('error')->addMessage(_('Your account is blocked.')); Zend_Controller_Action_HelperBroker::getStaticHelper('redirector')->direct('index', 'index', 'website'); } $login = new Editor_Models_Login(); $login->getStorage()->write($user); return; } } $resource = $request->getControllerName(); $actionName = $request->getActionName(); if ($authInstance->hasIdentity()) { if ($authInstance->getIdentity()->active != 'Y') { Zend_Auth::getInstance()->clearIdentity(); Zend_Session::forgetMe(); Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->setNamespace('error')->addMessage(_('Your account is blocked.')); Zend_Controller_Action_HelperBroker::getStaticHelper('redirector')->direct('index', 'index', 'website'); } } else { if ($request->getControllerName() != 'login') { Zend_Controller_Action_HelperBroker::getStaticHelper('redirector')->direct('index', 'login', 'editor'); } } }
/** * Processes the log out action * @return void */ public function logoutAction() { // Clean cookie Sydney_Http_Cookie::cleanAuthCookie(); Sydney_Auth::getInstance()->clearIdentity(); Zend_Session::forgetMe(); Zend_Session::destroy(); $this->logger->log('User logged OUT', Zend_Log::NOTICE); $this->redirect('/'); }
/** * Logout current user * * @return void */ public function logout() { $this->_auth->clearIdentity(); Zend_Session::forgetMe(); }
/** * Logs an user in the application based on his * username and email * * @param string $username * @param string $password * @param boolean $remember * @access public * @return void */ public function login($username, $password, $remember = FALSE) { // adapter cfg $adapter = new Zend_Auth_Adapter_DbTable($this->_db); $adapter->setTableName($this->_name); $adapter->setIdentityColumn('username'); $adapter->setCredentialColumn('password'); // checking credentials $adapter->setIdentity($username); $adapter->setCredential(BaseUser::hashPassword($password)); try { $result = $adapter->authenticate(); } catch (Zend_Auth_Adapter_Exception $e) { App_Logger::log(sprintf("Exception catched while login: %s", $e->getMessage()), Zend_Log::ERR); return FALSE; } if ($result->isValid()) { // get the user row $loggedUser = $adapter->getResultRowObject(NULL, 'password'); //Check if the account has been closed if ($loggedUser->deleted) { return NULL; } // clear the existing data $auth = Zend_Auth::getInstance(); $auth->clearIdentity(); if (!empty($loggedUser->id)) { switch (CURRENT_MODULE) { case 'frontend': $userModel = new User(); $user = $userModel->findById($loggedUser->id); $user->get('group'); $session = new stdClass(); foreach (get_object_vars($loggedUser) as $k => $v) { $session->{$k} = $v; } $session->group->name = $user->get('group')->name; break; case 'backoffice': $userModel = new BackofficeUser(); $user = $userModel->findById($loggedUser->id); $user->groups = $user->findManyToManyRowset('Group', 'BackofficeUserGroup'); $user->group = $user->groups[0]; $session = new stdClass(); foreach (get_object_vars($loggedUser) as $k => $v) { $session->{$k} = $v; } $session->group->name = $user->group->name; break; } $auth->getStorage()->write($session); } $this->update(array('last_login' => new Zend_Db_Expr('NOW()')), $this->_db->quoteInto('id = ?', $user->id)); if ($rememberMe) { Zend_Session::rememberMe(App_DI_Container::get('ConfigObject')->session->remember_me->lifetime); } else { Zend_Session::forgetMe(); } return TRUE; } else { return FALSE; } }
public function logoutAction() { Zend_Session::namespaceUnset('superadmin'); Zend_Auth::getInstance()->clearIdentity(); Zend_Session::forgetMe(); $this->_helper->FlashMessenger->addMessage(array('message' => 'Successfully logged out.')); $this->_redirect(''); }
/** * セッション終了時に有効期限が切れるように変更 * * @static * @access public */ public static function forgetMe() { parent::forgetMe(); }
public static function signOut() { Zend_Auth::getInstance()->clearIdentity(); Zend_Session::forgetMe(); }
public function logoutAction() { Zend_Session::forgetMe(); Zend_Auth::getInstance()->clearIdentity(); $this->_helper->getHelper('FlashMessenger')->addMessage('You are now logged out', 'success'); $this->_helper->redirector('login', 'auth'); // back to login page }
protected function _logout() { Zend_Auth::getInstance()->clearIdentity(); Zend_Session::forgetMe(); }
/** * "Выход" пользователя **/ public function logoutAction() { $cache_helper = $this->_helper->getHelper('MyCache'); $cache_helper->clearAllCacheRole($this->identity->role_id); /* * Final */ /* "Очищаем" данные об идентификации пользоваля */ Zend_Auth::getInstance()->clearIdentity(); Zend_Session::forgetMe(); /* Перебрасываем его на главную */ $this->_redirect('/'); }
public function logoutAction() { $auth = Zend_Auth::getInstance(); Zend_Session::namespaceUnset('userInfo'); Zend_Session::namespaceUnset('moduleList'); Zend_Session::namespaceUnset('paginator'); Zend_Session::forgetMe(); $auth->getInstance(); $auth->clearIdentity(); $this->_redirect($this->view->rootUrl('/admin/index/login')); }
/** * In CID we chose from the beginning not to use SET NAMES, and instead leave the charset encodings configurations * to remain in the database server side (my.cnf). * * CID's strings are UTF8. If character_set_client is not UTF8 but latin1 for example (unfortunatly that's the common case), non-latin1 * characters will appear garbled when manually browsing the db, but they should show OK in CID's web pages. * * When authenticating below, we use MySQL's MD5 function. From my tests, it looks like the argument of this function * gets automatically converted to the charset of that field. Sorta like if we had implicitly MD5(CONVERT(arg using charset)). * When the tables are build during setup, the charset of string fields are set accordingly to the my.cnf directives * character-set-server and collation-server. * If those directives don't match character_set_client, the conversion inside MD5 will in fact transform the string, and we'll * get the MD5 of a different string than what we had intended (well, only if the string contains non-latin1 characters). * For this reason we have to override that conversion, converting to the charset specified in character_set_client, as shown below. * * @return Zend_Auth_Result */ public function authenticate($identity, $password, $isOpenId = false, Zend_View $view = null, $bypassMarkSuccessfullLogin = false) { $config = Zend_Registry::get('config'); $useYubikey = false; if ($isOpenId) { if (!Zend_OpenId::normalize($identity)) { return false; } if (!($this->_user = $this->getUserWithOpenId($identity))) { return false; } $cn = $this->_user->username; } else { $cn = $identity; $this->_user = $this->getUserWithUsername($identity, false, $view); } if ($this->_user && $config->yubikey->enabled && ($this->_user->auth_type == Users_Model_User::AUTH_YUBIKEY || $config->yubikey->force)) { $parts = Yubico_Auth::parsePasswordOTP($password); if (!$parts || $this->_user->yubikey_publicid != $parts['prefix']) { return false; } $useYubikey = true; } $config = Zend_Registry::get('config'); $ldapConfig = $config->ldap; if ($useYubikey) { if (!@$config->yubikey->api_id || !@$config->yubikey->api_key) { throw new Zend_Exception('Admin must set the yubikey configuration options before attempting to log in using this method'); } $authAdapter = new Monkeys_Auth_Adapter_Yubikey(array('api_id' => $config->yubikey->api_id, 'api_key' => $config->yubikey->api_key), $identity, $password); } else { if ($ldapConfig->enabled) { $ldapOptions = $ldapConfig->toArray(); $ldapOptions['accountCanonicalForm'] = Zend_Ldap::ACCTNAME_FORM_USERNAME; unset($ldapOptions['enabled']); unset($ldapOptions['admin']); unset($ldapOptions['fields']); unset($ldapOptions['keepRecordsSynced']); unset($ldapOptions['canChangePassword']); unset($ldapOptions['passwordHashing']); // we'll try to bind directly as the user to be authenticated, so we're unsetting // the LDAP admin credentials unset($ldapOptions['username']); unset($ldapOptions['password']); $username = "******"; $authAdapter = new Zend_Auth_Adapter_Ldap(array('server1' => $ldapOptions), $username, $password); } else { $db = $this->getAdapter(); $result = $db->query("SHOW VARIABLES LIKE 'character_set_client'")->fetch(); $clientCharset = $result['Value']; if ($isOpenId) { $authAdapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'openid', 'password', 'MD5(CONCAT(CONVERT(openid using ' . $clientCharset . '), CONVERT(? using ' . $clientCharset . ')))'); } else { $authAdapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'username', 'password', 'MD5(CONCAT(CONVERT(openid using ' . $clientCharset . '), CONVERT(? using ' . $clientCharset . ')))'); } $authAdapter->setIdentity($identity); $authAdapter->setCredential($password); } } $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { if (!$isOpenId) { try { $this->_user = $this->getUserWithUsername($identity, true, $view); } catch (Exception $e) { // avoid leaving in the session an empty user object Zend_Auth::getInstance()->clearIdentity(); Zend_Session::forgetMe(); throw $e; } } if (!$bypassMarkSuccessfullLogin) { $this->_user->markSuccessfullLogin(); } $this->_user->save(); $auth->getStorage()->write($this->_user); Zend_Registry::set('user', $this->_user); return true; } // this is ugly, logging should be done in the controller, not here $logger = Zend_Registry::get('logger'); $logger->log("Invalid authentication: " . implode(' - ', $result->getMessages()), Zend_Log::DEBUG); if (is_a($authAdapter, 'Monkeys_Auth_Adapter_Yubikey')) { $authOptions = $authAdapter->getOptions(); if ($yubi = @$authOptions['yubiClient']) { $logger->log("Yubi request was: " . $yubi->getlastQuery(), Zend_Log::DEBUG); } } return false; }
public function loginAction() { if (vkNgine_Auth::isAuthenticated()) { $this->_redirect('/admin'); exit; } $view = Zend_Registry::get('view'); $view->headTitle('Administrator Login'); $loginForm = $this->getAdminLoginForm(); $recoverForm = $this->getAdminRecoverForm(); $request = $this->getRequest(); if ($request->isPost()) { $email = $this->_getParam('email'); $password = $this->_getParam('password'); $remember = $this->_getParam('remember'); $hash = new Zend_Session_Namespace('CsrfError'); if ($hash->message) { echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_($hash->message), 'icon' => 'error')); exit; } else { if ($loginForm->isValid($request->getPost())) { if (!empty($email) && !empty($password)) { $info = array('email' => $email, 'password' => $password, 'remember' => $remember); if (vkNgine_Admin_Auth::attemptLogin($info)) { $this->user = vkNgine_Admin_Auth::revalidate(); if (isset($info['remember']) and $info['remember']) { $config = vkNgine_Config::getSystemConfig(); if (isset($config->settings->login->remember)) { $rememberMeHowLong = $config->settings->login->remember; } else { $rememberMeHowLong = 60 * 60 * 24 * 14; // 14 days } Zend_Session::rememberMe($rememberMeHowLong); } else { Zend_Session::forgetMe(); } $logger = Zend_Registry::get('logger'); $logger->log('ADMIN_LOGIN_REQUEST', print_r($info, true), vkNgine_Log::INFO, $this->user['userId']); $modelTrafficLogins = new vkNgine_Log_Logins(); $modelTrafficLogins->insertTrafficLogin($this->user['userId'], 'ADMIN'); $modelTrafficActivity = new vkNgine_Log_Activity(); $modelTrafficActivity->processActivity($this->user, $request, 'Logged in to Admin Panel'); $modelUsers = new Admin_Model_Users(); $modelUsers->update($this->user['userId'], array('lastLogin' => date('Y-m-d H:i:s'))); echo Zend_Json::encode(array('success' => 1, 'title' => $this->t->_('Success Message'), 'message' => $this->t->_('Logged in Successfully'), 'icon' => 'success', 'href' => '/admin')); exit; } else { echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Invalid Login or Password!'), 'icon' => 'error')); exit; } } else { echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Username or Password is Invalid!'), 'icon' => 'error')); exit; } } else { echo Zend_Json::encode(array('title' => $this->t->_('Error Message'), 'message' => $this->t->_('Username or Password is Invalid!'), 'icon' => 'error')); exit; } } } $this->view->loginForm = $loginForm; $this->view->recoverForm = $recoverForm; }
public function loginAction() { if (!is_admin_theme()) { $referer = rtrim($_SERVER['HTTP_REFERER'], '/'); $master = rtrim(MASTER_URL, '/'); $login = $master . '/users/login'; if (isset($_SERVER['HTTP_REFERER']) && is_integer(strpos($referer, $master)) && $referer != $master && $referer != $login && !strpos($referer, '/users/activate')) { $session = new Zend_Session_Namespace(); $session->redirect = $_SERVER['HTTP_REFERER']; } } // require_once is necessary because lacking form autoloading. require_once APP_DIR . '/forms/Login.php'; $loginForm = new Omeka_Form_Login(); $loginForm = apply_filters('login_form', $loginForm); $this->view->form = $loginForm; if (!$this->getRequest()->isPost()) { return; } if ($loginForm instanceof Zend_Form && !$loginForm->isValid($_POST)) { return; } User::upgradeHashedPassword($loginForm->getValue('username'), $loginForm->getValue('password')); $authAdapter = new Omeka_Auth_Adapter_UserTable($this->_helper->db->getDb()); $pluginBroker = $this->getInvokeArg('bootstrap')->getResource('Pluginbroker'); // If there are no plugins filtering the login adapter, set the // credentials for the default adapter. if (!$pluginBroker || !$pluginBroker->getFilters('login_adapter')) { $authAdapter->setIdentity($loginForm->getValue('username'))->setCredential($loginForm->getValue('password')); } else { $authAdapter = apply_filters('login_adapter', $authAdapter, array('login_form' => $loginForm)); } $authResult = $this->_auth->authenticate($authAdapter); if (!$authResult->isValid()) { if ($log = $this->_getLog()) { $ip = $this->getRequest()->getClientIp(); $log->info("Failed login attempt from '{$ip}'."); } $this->_helper->flashMessenger($this->getLoginErrorMessages($authResult), 'error'); return; } if ($loginForm && $loginForm->getValue('remember')) { // Remember that a user is logged in for the default amount of // time (2 weeks). Zend_Session::rememberMe(); } else { // If a user doesn't want to be remembered, expire the cookie as // soon as the browser is terminated. Zend_Session::forgetMe(); } $session = new Zend_Session_Namespace(); if ($session->redirect) { $this->_helper->redirector->gotoUrl($session->redirect); } else { $this->_helper->redirector->gotoUrl('/'); } }
<?php /* * Script: login.php * Login page * * License: * GPL v3 or above */ $menu = false; // we must never forget to start the session //so config.php works ok without using index.php define browse define("BROWSE","browse"); //Zend_Auth::clearIdentity(); Zend_Session::forgetMe(); Zend_Session::destroy(true); header('Location: .');
public function logoutAction() { Zend_Auth::getInstance()->clearIdentity(); Zend_Session::forgetMe(); $this->_redirect('/'); }
public function indexAction() { Zend_Auth::getInstance()->clearIdentity(); Zend_Session::forgetMe(); $this->_helper->redirector('index', 'index', 'website'); }