You are here

function password_policy_user_presave in Password Policy 8.3

Same name and namespace in other branches
  1. 7.2 password_policy.module \password_policy_user_presave()
  2. 7 password_policy.module \password_policy_user_presave()

File

./password_policy.module, line 246
Module file for the Password Policy module.

Code

function password_policy_user_presave(EntityInterface $entity) {
  if (!$entity
    ->id()) {
    $date = \Drupal::service('date.formatter')
      ->format(\Drupal::time()
      ->getRequestTime(), 'custom', DateTimeItemInterface::DATETIME_STORAGE_FORMAT, DateTimeItemInterface::STORAGE_TIMEZONE);
    $entity
      ->set('field_last_password_reset', $date);
    $entity
      ->set('field_password_expiration', '0');
  }
}