public function AccountProxy::hasPermission in Restrict Login or Role Access by IP Address 8.4
Checks whether a user has a certain permission.
Parameters
string $permission: The permission string to check.
Return value
bool TRUE if the user has the permission, FALSE otherwise.
Overrides AccountInterface::hasPermission
File
- src/
Session/ AccountProxy.php, line 57 - Contains \Drupal\restrict_by_ip\Session\AccountProxy.
Class
- AccountProxy
- When the current user is loaded, remove any roles that are restricted based on IP whitelists. Proxy all other method calls to the original current_user service.
Namespace
Drupal\restrict_by_ip\SessionCode
public function hasPermission($permission) {
// User #1 has all privileges.
if ((int) $this
->id() === 1) {
return TRUE;
}
return $this
->getRoleStorage()
->isPermissionInRoles($permission, $this
->getRoles());
}