You are here

function force_password_change_user_insert in Force Password Change 2.0.x

Same name and namespace in other branches
  1. 8 force_password_change.module \force_password_change_user_insert()
  2. 7.2 force_password_change.module \force_password_change_user_insert()
  3. 7 force_password_change.module \force_password_change_user_insert()

Implements hook_user_insert().

File

./force_password_change.module, line 212

Code

function force_password_change_user_insert($account) {

  // If the site settings require users to change their password on
  // first time login, the user's account is flagged to have the
  // password changed.
  if (\Drupal::config('force_password_change.settings')
    ->get('first_time_login_password_change')) {
    $force_password_change_service = \Drupal::service('force_password_change.service');
    $force_password_change_service
      ->forceUserPasswordChange($account
      ->id());
    $force_password_change_service
      ->addFirstTimeLogin($account
      ->id());
  }
}