From 2ff1e36279d9176331de582f237bd8ee83dd679f Mon Sep 17 00:00:00 2001 From: Matthew Slater <matslats@fastmail.com> Date: Tue, 3 Nov 2020 20:37:32 +0100 Subject: [PATCH] updated default config --- alt_login.install | 14 -------------- alt_login.module | 6 +++++- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/alt_login.install b/alt_login.install index 6ada5e7..bb975d2 100644 --- a/alt_login.install +++ b/alt_login.install @@ -7,18 +7,4 @@ function alt_login_update_8001() { $settings = \Drupal::configFactory() ->getEditable('alt_login.settings') ->clear('name_mode'); - $modes = $settings->get('login'); - foreach ($modes as $key => $value) { - if ($value = 0) { - $modes[$key] = ALT_LOGIN_WITH_USERNAME; - } - elseif($value = 1) { - $modes[$key] = ALT_LOGIN_WITH_UID; - - } - elseif($value = 2) { - $modes[$key] = ALT_LOGIN_WITH_EMAIL; - } - } - $settings->set('login', $modes)->save(); } diff --git a/alt_login.module b/alt_login.module index b6d83af..f037733 100644 --- a/alt_login.module +++ b/alt_login.module @@ -6,7 +6,6 @@ use Drupal\user\Entity\User; use Drupal\user\UserInterface; -use Drupal\alt_login\AltLoginMethodManager; /** * Implements hook_help(). @@ -191,6 +190,10 @@ function alt_login_tokens_alter(&$replacements, array $context, $bubbleable_meta */ function alt_login_user_presave(UserInterface $account) { if ($account->isNew()) { + // Awkwardly, users migrating in are have isNew = true. + if ($account->getCreatedTime() < Drupal::time()->getRequestTime()) { + return; + } // Contrive a username if the username isn't otherwise used. $plugins = \Drupal::Config('alt_login.settings')->get('aliases'); if (!in_array('username', $plugins)) { @@ -210,6 +213,7 @@ function alt_login_user_presave(UserInterface $account) { $new_name .= '_'.$inc; } $account->setUsername($new_name); + \Drupal::logger('Alt Login')->notice('New user name set to '.$new_name); } } } -- GitLab