當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TokenInterface::setAuthenticated方法代碼示例

本文整理匯總了PHP中Symfony\Component\Security\Core\Authentication\Token\TokenInterface::setAuthenticated方法的典型用法代碼示例。如果您正苦於以下問題:PHP TokenInterface::setAuthenticated方法的具體用法?PHP TokenInterface::setAuthenticated怎麽用?PHP TokenInterface::setAuthenticated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Security\Core\Authentication\Token\TokenInterface的用法示例。


在下文中一共展示了TokenInterface::setAuthenticated方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: authenticate

 public function authenticate(TokenInterface $token)
 {
     $user = $this->userProvider->loadUserByUsername($token->getUsername());
     if (empty($user) || $user->checkToken($token->token) === false) {
         throw new AuthenticationException('Token authentication failed.');
     }
     $token->setAuthenticated(true);
     $token->setUser($user);
     return $token;
 }
開發者ID:rimi-itk,項目名稱:bpi-web-service,代碼行數:10,代碼來源:PKProvider.php

示例2: authenticate

 public function authenticate(TokenInterface $token)
 {
     $this->service_container->get($this->wordpress_loader_id)->load();
     $user = wp_get_current_user();
     if (isset($user->data) && isset($user->data->user_nicename)) {
         $token->setUser($user->data->user_email);
         $token->setAuthenticated(true);
         //$token->setRoles(array());
     } else {
         $token->setRedirectUrl($this->redirect_url);
     }
     return $token;
 }
開發者ID:cmoncy,項目名稱:WordpressBundle,代碼行數:13,代碼來源:WordpressAuthenticationProvider.php

示例3: authenticate

 public function authenticate(TokenInterface $token)
 {
     $token->setAuthenticated(true);
     return $token;
 }
開發者ID:makinacorpus,項目名稱:drupal-sf-dic,代碼行數:5,代碼來源:SecurityNullAuthenticationManager.php

示例4: setAuthenticated

 public function setAuthenticated($isAuthenticated)
 {
     $this->innerToken->setAuthenticated($isAuthenticated);
 }
開發者ID:emodric,項目名稱:LegacyBridge,代碼行數:4,代碼來源:LegacyToken.php

示例5: refreshUser

 /**
  * Refreshes the user by reloading it from the user provider
  *
  * @param TokenInterface $token
  *
  * @return TokenInterface|null
  */
 protected function refreshUser(TokenInterface $token)
 {
     $user = $token->getUser();
     if (!$user instanceof AccountInterface) {
         return $token;
     }
     if (null !== $this->logger) {
         $this->logger->debug(sprintf('Reloading user from user provider.'));
     }
     foreach ($this->userProviders as $provider) {
         try {
             $cUser = $provider->loadUserByAccount($user);
             $token->setRoles($cUser->getRoles());
             $token->setUser($cUser);
             if (false === $cUser->equals($user)) {
                 $token->setAuthenticated(false);
             }
             if (null !== $this->logger) {
                 $this->logger->debug(sprintf('Username "%s" was reloaded from user provider.', $user));
             }
             return $token;
         } catch (UnsupportedAccountException $unsupported) {
             // let's try the next user provider
         } catch (UsernameNotFoundException $notFound) {
             if (null !== $this->logger) {
                 $this->logger->debug(sprintf('Username "%s" could not be found.', $user));
             }
             return null;
         }
     }
     throw new \RuntimeException(sprintf('There is no user provider for user "%s".', get_class($user)));
 }
開發者ID:faridos,項目名稱:ServerGroveLiveChat,代碼行數:39,代碼來源:ContextListener.php


注:本文中的Symfony\Component\Security\Core\Authentication\Token\TokenInterface::setAuthenticated方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。