public function LoginHistoryController::checkUserReportAccess in Login History 8
Checks access for the user login report.
Parameters
\Drupal\user\UserInterface|null $user: The user to check access for.
Return value
\Drupal\Core\Access\AccessResult Returns Allowed or Neutral.
File
- src/
Controller/ LoginHistoryController.php, line 169
Class
- LoginHistoryController
- Controller routines for Login history routes.
Namespace
Drupal\login_history\ControllerCode
public function checkUserReportAccess(UserInterface $user = NULL) {
// Allow access if the user is viewing their own report and has permission
// or if the user has permission to view all login history reports.
$access = $user
->id() == $this
->currentUser()
->id() && $this->currentUser
->hasPermission('view own login history') || $this->currentUser
->hasPermission('view all login histories');
return AccessResult::allowedIf($access);
}