本文整理汇总了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)));
}