You are here

public function CasTestSubscriber::onPreLogin in CAS 2.x

Same name and namespace in other branches
  1. 8 tests/modules/cas_test/src/CasTestSubscriber.php \Drupal\cas_test\CasTestSubscriber::onPreLogin()

Cancels the login.

Parameters

\Drupal\cas\Event\CasPreLoginEvent $event: The event.

File

tests/modules/cas_test/src/CasTestSubscriber.php, line 51

Class

CasTestSubscriber
Subscribes to pre-login and pre-register events.

Namespace

Drupal\cas_test

Code

public function onPreLogin(CasPreLoginEvent $event) {
  $flag = \Drupal::state()
    ->get('cas_test.flag');
  if ($flag === 'cancel login without message') {
    $event
      ->cancelLogin();
  }
  elseif ($flag === 'cancel login with message') {
    $event
      ->cancelLogin('Cancelled with a custom message.');
  }
}