本文整理匯總了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;
}
示例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;
}
示例3: authenticate
public function authenticate(TokenInterface $token)
{
$token->setAuthenticated(true);
return $token;
}
示例4: setAuthenticated
public function setAuthenticated($isAuthenticated)
{
$this->innerToken->setAuthenticated($isAuthenticated);
}
示例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)));
}