public function __invoke(Request $req, Response $res, callable $next) { $res = $next($req, $res); $identity = $this->authService->getIdentity(); if (!$identity) { return $res; } try { $user = R::findOne('user', 'mail = ?', [$identity->mail]); if (!$user) { $user = R::dispense('user'); $user->uid = $identity->uid; $user->mail = $identity->mail; $user->display_name = $identity->displayName; $user->office_name = $identity->officeName; $user->authentication_source = $identity->authenticationSource; $user->password = ''; $user->created = time(); $user->role = 'school'; $this->logger->info(sprintf('User %s imported from sso.sch.gr to database', $identity->mail)); } $user->last_login = time(); $user_id = R::store($user); $identityClass = get_class($identity); $newIdentity = new $identityClass($user_id, $user->uid, $user->mail, $user->display_name, $user->office_name, $user->authentication_source); $this->authService->getStorage()->write($newIdentity); } catch (\Exception $e) { $this->authService->clearIdentity(); $this->flash->addMessage('danger', 'A problem occured storing user in database. <a href="%s" title="SSO logout">SSO Logout</a>'); $this->logger->error('Problem inserting user form CAS in database', $identity->toArray()); $this->logger->debug('Exception', [$e->getMessage(), $e->getTraceAsString()]); return $res->withRedirect($this->userErrorRedirectUrl); } return $res; }
public function logoutAction() { if ($this->identity()) { $this->authenticationService->clearIdentity(); } return $this->redirect()->toRoute('home'); }
public function logout() { if ($this->authService->hasIdentity()) { $this->authService->clearIdentity(); $this->sessionManager->forgetMe(); } }
/** * Handle logout process * * @param GetResponseEvent $event */ public function onKernelRequest(GetResponseEvent $event) { if ($this->logout->matches($event->getRequest())) { $this->authentication->clearIdentity(); if ($this->target) { // Target can be null for user defined controller behaviour $event->setResponse(new RedirectResponse((string) $this->target)); } } }
/** * {@inheritDoc} */ public function getIdentityRoles() { //if user was manually deleted from storage we should clear identity if ($this->authService->hasIdentity() && !$this->authService->getIdentity()) { $this->authService->clearIdentity(); } if (!$this->authService->hasIdentity()) { return array($this->getDefaultRole()); } return $this->authService->getIdentity()->getUser()->getRole(); }
public function logoutAction() { $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage('SONUser')); $auth->clearIdentity(); return $this->redirect()->toRoute('sonuser-auth'); }
public function logoutAction() { $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage("geframa_admin")); $auth->clearIdentity(); return $this->redirect()->toRoute('geframa_login'); }
public function logoutAction() { Utility::insertHistory('logout'); $auth = new AuthenticationService(); $auth->clearIdentity(); $this->redirect()->toRoute('admin/child', array('controller' => 'login')); }
public function authenticate($username, $password) { $callback = function ($password, $hash) { $bcrypt = new Bcrypt(); return $bcrypt->verify($hash, $password); }; $authenticationService = new AuthenticationService(); $callbackCheckAdapter = new CallbackCheckAdapter($this->dbAdapter, "users", 'username', 'password', $callback); $callbackCheckAdapter->setIdentity($username)->setCredential($password); $authenticationService->setAdapter($callbackCheckAdapter); $authResult = $authenticationService->authenticate(); if ($authResult->isValid()) { $userObject = $callbackCheckAdapter->getResultRowObject(); $authenticationService->getStorage()->write($userObject); if ($userObject->status == 0) { $authenticationService->clearIdentity(); $this->setCode(-5); return false; } else { return true; } } else { $this->setCode($authResult->getCode()); return false; } }
/** * preDispatch Event Handler * Handle authentication process * Decide where user should be redirected to when logged in or not * * * @access public * @uses AuthenticationService * @uses Response * * @param \Zend\Mvc\MvcEvent $event * @throws \Exception */ public function preDispatch(MvcEvent $event) { // ACL dispatcher is used only in HTTP requests not console requests if (!$event->getRequest() instanceof HttpRequest) { return; } $userAuth = new AuthenticationService(); $user = array(); $signInController = 'DefaultModule\\Controller\\Sign'; if ($userAuth->hasIdentity()) { $user = $userAuth->getIdentity(); } $routeMatch = $event->getRouteMatch(); $controller = $routeMatch->getParam('controller'); $action = $routeMatch->getParam('action'); if ($userAuth->hasIdentity() && isset($user['status']) && $user['status'] == 2) { $userAuth->clearIdentity(); // redirect to sign/out $url = $event->getRouter()->assemble(array('action' => 'out'), array('name' => 'defaultSign')); } else { if ($userAuth->hasIdentity() && $controller == $signInController && $action == 'in') { // redirect to index $url = $event->getRouter()->assemble(array('action' => 'index'), array('name' => 'home')); } } if (isset($url)) { $event->setResponse(new Response()); $this->redirect()->getController()->setEvent($event); $response = $this->redirect()->toUrl($url); return $response; } }
public function logoutAction() { $auth = new AuthenticationService(); //$auth->setStorage(new SessionStorage("ACPLOUser")); $auth->clearIdentity(); return $this->redirect()->toRoute('acplouser-auth'); }
public function clearIdentity() { parent::clearIdentity(); // Remove authentication indicator cookie $expires = time() - 3600; $this->setCookie('', $expires); }
public function logoutAction() { $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage("auth_enquete")); $auth->clearIdentity(); $this->redirect()->toRoute("auth"); }
/** * Logout user * * @return \Zend\Http\Response */ public function logoutAction() { $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage('BookstoreAdmin')); $auth->clearIdentity(); return $this->redirect()->toRoute('bookstore-admin-auth'); }
/** * Faz o logout do sistema * * @return void */ public function logout() { $auth = new AuthenticationService(); $session = $this->getServiceManager()->get('Session'); $session->offsetUnset('sysUserData'); $auth->clearIdentity(); return true; }
public function logoutAction() { $auth = new AuthenticationService(); if ($auth->hasIdentity()) { $auth->clearIdentity(); } return $this->redirect()->toRoute('home'); }
public function logoutAction() { $auth = new AuthenticationService(); $auth->setStorage(new SessionStorage('FuncSessao')); #Definindo session storage pra auth $auth->clearIdentity(); return $this->redirect()->toUrl('/application/auth/index'); }
public function __invoke(Request $request, Response $response, callable $next) { $auth = new AuthenticationService(); if ($auth->hasIdentity()) { $auth->clearIdentity(); } return $next($request, $response); }
/** * User Logout * * * @uses AuthenticationService * * @access public */ public function outAction() { $auth = new AuthenticationService(); // clear user-related data in session $auth->clearIdentity(); // Redirect to login page again $url = $this->getEvent()->getRouter()->assemble(array('action' => 'in'), array('name' => 'defaultSign')); $this->redirect()->toUrl($url); }
public function logoutAction() { // Clear the identity and we also regenerate a new session id in order to make sure that new logins always // have a unique session id. $this->authenticationService->clearIdentity(); $this->authSession->getManager()->expireSessionCookie(); $this->resetTwoFactorAuthentication(); return $this->redirect()->toRoute('login'); }
public function deconnexionAction() { $auth = new AuthenticationService(); $auth->clearIdentity(); $sessionManager = Container::getDefaultManager(); $sessionManager->destroy(); $this->flashMessenger()->addSuccessMessage('Vous avez bien été déconnecté(e).'); return $this->redirect()->toRoute('accueil'); }
public function logoutAction() { $auth = new AuthenticationService(); if ($auth->hasIdentity()) { //$identity = $auth->getIdentity(); $auth->clearIdentity(); $this->flashMessenger()->addSuccessMessage('Voce acabou de ser desconectado!'); } //$this->_redirect('/user'); return $this->redirect()->toRoute('home', array('controller' => 'home', 'action' => 'index')); }
public function logoutAction() { $auth = new AuthenticationService(); if ($auth->hasIdentity()) { $identity = $auth->getIdentity(); } $auth->clearIdentity(); $sessionManager = new \Zend\Session\SessionManager(); $sessionManager->forgetMe(); return $this->redirect()->toRoute('myauth', array('controller' => 'index', 'action' => 'login')); }
public function logoutAction() { $auth = new AuthenticationService(); if ($auth->hasIdentity()) { $identity = $auth->getIdentity(); $auth->clearIdentity(); $sessionManager = new SessionManager(); $sessionManager->forgetMe(); } $this->redirect()->toRoute('backend_login'); }
public function indexAction() { /** @var User $identity */ $identity = $this->identity(); $user = User::with('profile', 'tasks')->find($identity->id); if (!$user) { $this->flashMessenger()->addErrorMessage($this->translate('Your account data could not be loaded. Please try to login before.')); $this->authenticationService->clearIdentity(); return $this->redirect()->toRoute('users', ['controller' => 'authentication', 'action' => 'login']); } $viewModel = new ViewModel(['form' => $this->tasksForm]); $this->tasksForm->bind($user); if ($this->getRequest()->isPost()) { $this->tasksForm->setData($this->getRequest()->getPost()); if ($this->tasksForm->isValid()) { $this->usersRepo->save($user); $this->flashMessenger()->addSuccessMessage($this->translate('Tasks & data updated succesfully')); return $this->redirect()->toRoute('tasks', ['controller' => 'manage', 'action' => 'index']); } } return $viewModel; }
public function logoutAction() { $auth = new AuthenticationService(); // or prepare in the globa.config.php and get it from there // $auth = $this->getServiceLocator()->get('Zend\Authentication\AuthenticationService'); if ($auth->hasIdentity()) { $identity = $auth->getIdentity(); } $auth->clearIdentity(); // $auth->getStorage()->session->getManager()->forgetMe(); // no way to get the sessionmanager from storage $sessionManager = new \Zend\Session\SessionManager(); $sessionManager->forgetMe(); return $this->redirect()->toRoute('auth'); }
public function __invoke(Request $request, Response $response, callable $next) { $auth = new AuthenticationService(); if ($auth->hasIdentity()) { $auth->clearIdentity(); } /* $render = $this->template->render('app::login'); $query = $request->getParsedBody(); $query['view']['render'] = $render; $query['view']['code'] = 200; $request = $request->withParsedBody($query);*/ return $next($request, $response); }
public function logoutAction() { $auth = new AuthenticationService(); // or prepare in the globa.config.php and get it from there // $auth = $this->getServiceLocator()->get('Zend\Authentication\AuthenticationService'); if ($auth->hasIdentity()) { $identity = $auth->getIdentity(); } $container = new Container('adminloginuser'); unset($container->userdetail); unset($container->userid); $auth->clearIdentity(); // $auth->getStorage()->session->getManager()->forgetMe(); // no way to get the sessionmanager from storage $sessionManager = new \Zend\Session\SessionManager(); $sessionManager->forgetMe(); return $this->redirect()->toRoute('admin/default', array('controller' => 'index', 'action' => 'login')); }
public function passwordRecoverAction() { $identityRepo = $this->entityManager->getRepository($this->config['identityClass']); $credentialRepo = $this->entityManager->getRepository($this->config['credentialClass']); $token = $this->params()->fromRoute('token', 0); if ($this->identity()) { $this->authenticationService->getStorage()->forgetMe(); $this->authenticationService->clearIdentity(); } $qb = $identityRepo->createQueryBuilder('i'); $qb->where('i.token = :token'); $qb->setParameter('token', $token); /** @var UserInterface $identity */ $identity = $qb->getQuery()->getOneOrNullResult(); if ($identity == null) { $this->flashMessenger()->addErrorMessage(_('Token invalid or you already confirmed this link.')); return $this->redirect()->toRoute($this->routes['signin']['name'], $this->routes['signin']['params'], $this->routes['signin']['options'], $this->routes['signin']['reuseMatchedParams']); } $form = new PasswordChangeForm(); $this->routes['password-recover']['params']['token'] = $token; $form->setAttribute('action', $this->url()->fromRoute($this->routes['password-recover']['name'], $this->routes['password-recover']['params'], $this->routes['password-recover']['options'], $this->routes['password-recover']['reuseMatchedParams'])); $form->getInputFilter()->get('password-old')->setRequired(false); $request = $this->getRequest(); if ($request->isPost()) { $form->setData($request->getPost()); if ($form->isValid()) { $data = $form->getData(); $credential = $credentialRepo->findOneBy(array($this->config['credentialIdentityProperty'] => $identity, 'type' => $this->config['credentialType'])); $passwordNew = sha1(sha1($data['password-new'])); $identity->setToken(sha1(uniqid(mt_rand(), true))); $credential->setValue($passwordNew); $this->entityManager->flush(); $this->flashMessenger()->addSuccessMessage(_('Your password has been changed successfully!')); return $this->redirect()->toRoute($this->routes['signin']['name'], $this->routes['signin']['params'], $this->routes['signin']['options'], $this->routes['signin']['reuseMatchedParams']); } else { $this->flashMessenger()->addErrorMessage(_('Form with errors!')); } } $form->prepare(); $viewModel = new ViewModel(['form' => $form, 'routes' => $this->routes]); $viewModel->setTemplate($this->templates['password-recover']); $this->layout($this->layoutView); return $viewModel; }
public function logoffAction() { $authenticationService = new AuthenticationService(); $authenticationService->clearIdentity(); return $this->redirect()->toRoute('authentication'); }