You are here

function timezone_detect_user_login in Timezone Detect 8

Same name and namespace in other branches
  1. 7 timezone_detect.module \timezone_detect_user_login()

Implements hook_user_login().

File

./timezone_detect.module, line 13
Module provides automatic timezone detection via javascript.

Code

function timezone_detect_user_login(UserInterface $account) {
  $timezone_detect_settings = \Drupal::config('timezone_detect.settings');
  if ($timezone_detect_settings
    ->get('mode') === TimezoneDetectInterface::MODE_LOGIN || empty($account->timezone)) {

    // Set session flag to update user's timezone. Note that we cannot add the
    // js directly from this function, as the user is redirected after this
    // hook fires.
    $_SESSION['timezone_detect']['update_timezone'] = TRUE;
  }
}