You are here

public function UloginAccess::access in uLogin (advanced version) 8

Check if user can access specified group.

Parameters

\Symfony\Component\Routing\Route $route: Current route.

\Drupal\Core\Routing\RouteMatchInterface $route_match: Current route match.

\Drupal\Core\Session\AccountInterface $account: User.

Return value

\Drupal\Core\Access\AccessResult Result.

File

src/Access/UloginAccess.php, line 29

Class

UloginAccess
Ulogin Access.

Namespace

Drupal\ulogin\Access

Code

public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account) {
  $access = AccessResult::neutral();
  $user = $account
    ->getAccount();
  if (($route_match
    ->getRawParameter('uid') == $user
    ->id() || $user
    ->hasPermission('administer users')) && $user
    ->isAuthenticated()) {
    return $access
      ->allowed();
  }
  return $access
    ->forbidden();
}