/** * This is called when an interactive authentication attempt succeeds. This * is called by authentication listeners inheriting from AbstractAuthenticationListener. * @param Request $request * @param TokenInterface $token * @return Response The response to return */ public function onAuthenticationSuccess(Request $request, TokenInterface $token) { $user = $token->getUser(); // This should actually be handle by the AuthenticationFailedHandler if (!$user->isAdmin()) { // can't go into admin $request->getSession()->set(SecurityContextInterface::AUTHENTICATION_ERROR, new AuthenticationException('User is not an admin.')); return $this->httpUtils->createRedirectResponse($request, 'admin_login'); } \LoginAttempts::DeleteOldLoginAttempts(); \LoginAttempts::ClearLoginAttemptsForIp(); $zendAuth = \Zend_Auth::getInstance(); $this->authAdapter->setUsername($user->getUsername())->setPassword($request->request->get('_password'))->setAdmin(true); $zendAuth->authenticate($this->authAdapter); $OAuthtoken = $this->userService->loginUser($user, 'oauth_authorize'); $session = $request->getSession(); $session->set('_security_oauth_authorize', serialize($OAuthtoken)); $frontendToken = $this->userService->loginUser($user, 'frontend_area'); $session = $request->getSession(); $session->set('_security_frontend_area', serialize($frontendToken)); \Article::UnlockByUser($user->getId()); $request->setLocale($request->request->get('login_language')); $this->setNoCacheCookie($request); $user->setLastLogin(new \DateTime()); $this->em->flush(); if ($request->get('ajax') === 'true') { // close popup with login. return new Response("<script type=\"text/javascript\">window.parent.g_security_token = '" . \SecurityToken::GetToken() . "';window.parent.\$(window.parent.document.body).data('loginDialog').dialog('close');window.parent.setSecurityToken(window.parent.g_security_token);</script>"); } return parent::onAuthenticationSuccess($request, $token); }
function camp_successful_login($user, $f_login_language) { global $ADMIN, $LiveUser, $LiveUserAdmin, $request, $requestId; $user->initLoginKey(); $data = array('KeyId' => $user->getKeyId()); if (is_object($LiveUser->_perm)) { $permUserId = $LiveUser->_perm->getProperty('perm_user_id'); $LiveUserAdmin->updateUser($data, $permUserId); $LiveUser->updateProperty(true, true); LoginAttempts::ClearLoginAttemptsForIp(); setcookie("LoginUserId", $user->getUserId()); setcookie("LoginUserKey", $user->getKeyId()); setcookie("TOL_Language", $f_login_language); Article::UnlockByUser($user->getUserId()); // Try to restore request. if (!empty($request)) { // restore request camp_session_set("request_$requestId", $request); $request = unserialize($request); camp_html_goto_page($request['uri'], TRUE, array( 'request' => $requestId, )); } // Go to admin index if no request is set. camp_html_goto_page("/$ADMIN/index.php"); } }
public function logoutAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { Article::UnlockByUser((int) $auth->getIdentity()); $auth->clearIdentity(); unset($_SESSION['statDisplayed']); } $this->_helper->FlashMessenger(getGS('You were logged out.')); $this->_helper->redirector('index', 'index'); }
public function logoutAction() { $translator = \Zend_Registry::get('container')->getService('translator'); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { Article::UnlockByUser((int) $auth->getIdentity()); $auth->clearIdentity(); setcookie('NO_CACHE', 'NO', time() - 3600, '/'); unset($_SESSION['statDisplayed']); } $this->_helper->FlashMessenger($translator->trans('You were logged out.', array(), 'users')); $this->_helper->redirector('index', 'index'); }
<?php $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { Article::UnlockByUser((int) $auth->getIdentity()); $auth->clearIdentity(); } camp_html_goto_page("/{$ADMIN}/login.php");
<?php require_once($GLOBALS['g_campsiteDir'].'/classes/Article.php'); $LiveUser->logout(); // Delete the cookies setcookie('LoginUserId', '', time() - 86400); setcookie('LoginUserKey', '', time() - 86400); setcookie('PHPSESSID', '', time() - 86400); @session_destroy(); // Unlock all articles that are locked by this user Article::UnlockByUser($g_user->getUserId()); camp_html_goto_page("/$ADMIN/login.php"); ?>