当前位置: 首页>>代码示例>>PHP>>正文


PHP AuthenticationService::clearIdentity方法代码示例

本文整理汇总了PHP中Zend\Authentication\AuthenticationService::clearIdentity方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthenticationService::clearIdentity方法的具体用法?PHP AuthenticationService::clearIdentity怎么用?PHP AuthenticationService::clearIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Authentication\AuthenticationService的用法示例。


在下文中一共展示了AuthenticationService::clearIdentity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __invoke

 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;
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:35,代码来源:CreateUser.php

示例2: logoutAction

 public function logoutAction()
 {
     if ($this->identity()) {
         $this->authenticationService->clearIdentity();
     }
     return $this->redirect()->toRoute('home');
 }
开发者ID:DavBfr,项目名称:BlogMVC,代码行数:7,代码来源:ConnexionController.php

示例3: logout

 public function logout()
 {
     if ($this->authService->hasIdentity()) {
         $this->authService->clearIdentity();
         $this->sessionManager->forgetMe();
     }
 }
开发者ID:sauron07,项目名称:rest_helper,代码行数:7,代码来源:UserService.php

示例4: onKernelRequest

 /**
  * 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));
         }
     }
 }
开发者ID:sunnyct,项目名称:silexcmf-zend-authentication,代码行数:15,代码来源:LogoutListener.php

示例5: getIdentityRoles

 /**
  * {@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();
 }
开发者ID:zfury,项目名称:cmf,代码行数:14,代码来源:DoctrineProvider.php

示例6: logoutAction

 public function logoutAction()
 {
     $auth = new AuthenticationService();
     $auth->setStorage(new SessionStorage('SONUser'));
     $auth->clearIdentity();
     return $this->redirect()->toRoute('sonuser-auth');
 }
开发者ID:Tortinhex,项目名称:son-zf2-inter,代码行数:7,代码来源:AuthController.php

示例7: logoutAction

 public function logoutAction()
 {
     Utility::insertHistory('logout');
     $auth = new AuthenticationService();
     $auth->clearIdentity();
     $this->redirect()->toRoute('admin/child', array('controller' => 'login'));
 }
开发者ID:binnguyen,项目名称:kaffacoffee,代码行数:7,代码来源:LoginController.php

示例8: authenticate

 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;
     }
 }
开发者ID:kalelc,项目名称:inventory,代码行数:26,代码来源:AuthSessionAdapter.php

示例9: preDispatch

 /**
  * 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;
     }
 }
开发者ID:camelcasetechsd,项目名称:certigate,代码行数:45,代码来源:AuthenticationEvent.php

示例10: logoutAction

 public function logoutAction()
 {
     $auth = new AuthenticationService();
     //$auth->setStorage(new SessionStorage("ACPLOUser"));
     $auth->clearIdentity();
     return $this->redirect()->toRoute('acplouser-auth');
 }
开发者ID:abelclopes,项目名称:ZF2-Intermediario-com-acl,代码行数:7,代码来源:AuthController.php

示例11: clearIdentity

 public function clearIdentity()
 {
     parent::clearIdentity();
     // Remove authentication indicator cookie
     $expires = time() - 3600;
     $this->setCookie('', $expires);
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:7,代码来源:AuthenticationService.php

示例12: logoutAction

 public function logoutAction()
 {
     $auth = new AuthenticationService();
     $auth->setStorage(new SessionStorage("auth_enquete"));
     $auth->clearIdentity();
     $this->redirect()->toRoute("auth");
 }
开发者ID:felipe1070,项目名称:testeXyz,代码行数:7,代码来源:AuthController.php

示例13: logoutAction

 /**
  * 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');
 }
开发者ID:argentinaluiz,项目名称:Learning-ZF2,代码行数:12,代码来源:AuthController.php

示例14: logout

 /**
  * 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;
 }
开发者ID:cepheros,项目名称:zf2-doctrine,代码行数:13,代码来源:System.php

示例15: logoutAction

 public function logoutAction()
 {
     $auth = new AuthenticationService();
     if ($auth->hasIdentity()) {
         $auth->clearIdentity();
     }
     return $this->redirect()->toRoute('home');
 }
开发者ID:alclin,项目名称:zend_framework,代码行数:8,代码来源:AuthController.php


注:本文中的Zend\Authentication\AuthenticationService::clearIdentity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。