function UserLoginBlock::blockAccess
Same name in other branches
- 9 core/modules/user/src/Plugin/Block/UserLoginBlock.php \Drupal\user\Plugin\Block\UserLoginBlock::blockAccess()
- 10 core/modules/user/src/Plugin/Block/UserLoginBlock.php \Drupal\user\Plugin\Block\UserLoginBlock::blockAccess()
- 11.x core/modules/user/src/Plugin/Block/UserLoginBlock.php \Drupal\user\Plugin\Block\UserLoginBlock::blockAccess()
File
-
core/
modules/ user/ src/ Plugin/ Block/ UserLoginBlock.php, line 73
Class
- UserLoginBlock
- Provides a 'User login' block.
Namespace
Drupal\user\Plugin\BlockCode
protected function blockAccess(AccountInterface $account) {
$route_name = $this->routeMatch
->getRouteName();
if ($account->isAnonymous() && !in_array($route_name, [
'user.login',
'user.logout',
])) {
return AccessResult::allowed()->addCacheContexts([
'route.name',
'user.roles:anonymous',
]);
}
return AccessResult::forbidden();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.