You are here

function paranoia_user_role_presave in Paranoia 8

File

./paranoia.module, line 35
Disables PHP block visibility permission and gives status error if a role has this permission. Disables the PHP module. Hides the PHP and paranoia modules from the modules page. Prevents user/1 editing which could give access to abitrary contrib…

Code

function paranoia_user_role_presave(RoleInterface $role) {
  if ($role
    ->isAdmin() || isset($role->original) && $role->original
    ->isAdmin()) {
    $role
      ->setIsAdmin(FALSE);
    \Drupal::service('logger.channel.paranoia')
      ->alert('An attempt to elevate the role %role_label to admin was detected and blocked.', [
      '%role_label' => $role
        ->label(),
    ]);
  }
}