You are here

class LogintobogganReValidateAccess in LoginToboggan 8

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

Hierarchy

Expanded class hierarchy of LogintobogganReValidateAccess

1 string reference to 'LogintobogganReValidateAccess'
logintoboggan.services.yml in ./logintoboggan.services.yml
logintoboggan.services.yml
1 service uses LogintobogganReValidateAccess
access_check.logintoboggan.revalidate_access in ./logintoboggan.services.yml
Drupal\logintoboggan\Access\LogintobogganReValidateAccess

File

src/Access/LogintobogganReValidateAccess.php, line 15

Namespace

Drupal\logintoboggan\Access
View source
class LogintobogganReValidateAccess implements RoutingAccessInterface {

  /**
   * {@inheritdoc}
   */
  public function appliesTo() {
    return [
      '_logintoboggan_revalidate_access',
    ];
  }

  /**
   * {@inheritdoc}
   */
  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();
  }

}

Members