You are here

public function LogintobogganReValidateAccess::access in LoginToboggan 8

File

src/Access/LogintobogganReValidateAccess.php, line 27

Class

LogintobogganReValidateAccess
Determines access to routes based on login status of current user.

Namespace

Drupal\logintoboggan\Access

Code

public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account) {
  $fullpath = Url::fromRoute('<current>')
    ->toString();
  $path_parts = explode('/', $fullpath);
  $user_id = $path_parts[3];
  return $account
    ->id() == $user_id || $account
    ->hasPermission('administer users') ? AccessResult::allowed() : AccessResult::forbidden();
}