You are here

public function ProtectedPagesLoginForm::accessProtectedPageLoginScreen in Protected Pages 8

Checks access based permission and protected page id.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

1 string reference to 'ProtectedPagesLoginForm::accessProtectedPageLoginScreen'
protected_pages.routing.yml in ./protected_pages.routing.yml
protected_pages.routing.yml

File

src/Form/ProtectedPagesLoginForm.php, line 92

Class

ProtectedPagesLoginForm
Provides login screen to access protected page.

Namespace

Drupal\protected_pages\Form

Code

public function accessProtectedPageLoginScreen() {
  $param_protected_page = $this
    ->getRequest()->query
    ->get('protected_page');
  $param_exists = isset($param_protected_page) && is_numeric($param_protected_page);
  return AccessResult::allowedIf(($this->currentUser
    ->hasPermission('access protected page password screen') || $this->currentUser
    ->id() == 1) && $param_exists);
}