You are here

function login_destination_user_login in Login Destination 8.2

Same name and namespace in other branches
  1. 8 login_destination.module \login_destination_user_login()
  2. 7 login_destination.module \login_destination_user_login()

Implements hook_user_login().

File

./login_destination.module, line 46
Control where users are directed to, once they login, register or logout.

Code

function login_destination_user_login(AccountInterface $account) {
  if (isset($account->user_is_new) && $account->user_is_new) {

    // User is just registered.
    login_destination_perform_redirect('registration', $account);
  }
  elseif (\Drupal::service('current_route_match')
    ->getRouteName() === 'user.reset.login') {
    if (\Drupal::config('login_destination.settings')
      ->get('immediate_redirect')) {

      // User used an one-time login link.
      login_destination_perform_redirect('one-time-login', $account);
    }
  }
  else {
    login_destination_perform_redirect('login', $account);
  }
}