public function AutoLoginUrlMainController::login in Auto Login URL 8
Same name and namespace in other branches
- 2.x src/Controller/AutoLoginUrlMainController.php \Drupal\auto_login_url\Controller\AutoLoginUrlMainController::login()
Auto login method.
Parameters
string $hash: The hash string on the URL.
1 string reference to 'AutoLoginUrlMainController::login'
File
- src/
Controller/ AutoLoginUrlMainController.php, line 17
Class
Namespace
Drupal\auto_login_url\ControllerCode
public function login($uid, $hash) {
// Disable page cache.
\Drupal::service('page_cache_kill_switch')
->trigger();
// Check for flood events.
if (\Drupal::service('auto_login_url.general')
->checkFlood()) {
drupal_set_message($this
->t('Sorry, too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later.'), 'error');
throw new AccessDeniedHttpException();
}
$destination = \Drupal::service('auto_login_url.login')
->login($uid, $hash);
if ($destination) {
return new RedirectResponse($destination);
}
else {
// Register flood event.
\Drupal::service('auto_login_url.general')
->registerFlood($hash);
throw new AccessDeniedHttpException();
}
}