本文整理汇总了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;
}
示例2: logoutAction
public function logoutAction()
{
if ($this->identity()) {
$this->authenticationService->clearIdentity();
}
return $this->redirect()->toRoute('home');
}
示例3: logout
public function logout()
{
if ($this->authService->hasIdentity()) {
$this->authService->clearIdentity();
$this->sessionManager->forgetMe();
}
}
示例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));
}
}
}
示例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();
}
示例6: logoutAction
public function logoutAction()
{
$auth = new AuthenticationService();
$auth->setStorage(new SessionStorage('SONUser'));
$auth->clearIdentity();
return $this->redirect()->toRoute('sonuser-auth');
}
示例7: logoutAction
public function logoutAction()
{
Utility::insertHistory('logout');
$auth = new AuthenticationService();
$auth->clearIdentity();
$this->redirect()->toRoute('admin/child', array('controller' => 'login'));
}
示例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;
}
}
示例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;
}
}
示例10: logoutAction
public function logoutAction()
{
$auth = new AuthenticationService();
//$auth->setStorage(new SessionStorage("ACPLOUser"));
$auth->clearIdentity();
return $this->redirect()->toRoute('acplouser-auth');
}
示例11: clearIdentity
public function clearIdentity()
{
parent::clearIdentity();
// Remove authentication indicator cookie
$expires = time() - 3600;
$this->setCookie('', $expires);
}
示例12: logoutAction
public function logoutAction()
{
$auth = new AuthenticationService();
$auth->setStorage(new SessionStorage("auth_enquete"));
$auth->clearIdentity();
$this->redirect()->toRoute("auth");
}
示例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');
}
示例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;
}
示例15: logoutAction
public function logoutAction()
{
$auth = new AuthenticationService();
if ($auth->hasIdentity()) {
$auth->clearIdentity();
}
return $this->redirect()->toRoute('home');
}