Hello,
I have faced the following error today while using the module with core 9.0.3:
Error: Call to undefined method Drupal\user\Entity\User::getUsername() in username_enumeration_prevention_pass_submit() (line 79 of \modules\contrib\username_enumeration_prevention\username_enumeration_prevention.module)
The following allows to fix it:
- Line 13:
+ use Drupal\Core\Session\AccountInterface;
- Line 79:
- \Drupal::logger('username_enumeration_prevention')->notice('Password reset instructions mailed to %name at %email.', ['%name' => $account->getUsername(), '%email' => $account->getEmail()]);
+ \Drupal::logger('username_enumeration_prevention')->notice('Password reset instructions mailed to %name at %email.', ['%name' => $account->getAccountName(), '%email' => $account->getEmail()]);
Hoping it helps the community!
Cheers,
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | fix-deprecated-getusername-3167106-2.patch | 1.02 KB | kirkkala |
Comments
Comment #2
kirkkalaThanks Arno2Mars!
I attached this same fix as a patch that allows the module to be used on D9 sites.
Tests need to be fixed.
Comment #3
chadmandoo commentedI am using Drupal 9 version of this module and the above patches is necessary in Drupal 9. Otherwise it throws an error. Testing the patch and it works. Please add to dev ASAP.
Comment #5
nicksanta commentedMerged! Thanks for the contribution! https://github.com/nicksantamaria/drupal-username_enumeration_prevention...