You are here

public function CasTestSubscriber::onPreLogin in CAS 8

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

Cancels the login.

Parameters

\Drupal\cas\Event\CasPreLoginEvent $event:

File

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

Class

CasTestSubscriber
Class CasTestSubscriber.

Namespace

Drupal\cas_test

Code

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