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,

Comments

Arno2Mars created an issue. See original summary.

kirkkala’s picture

Status: Active » Needs review
StatusFileSize
new1.02 KB

Thanks Arno2Mars!

I attached this same fix as a patch that allows the module to be used on D9 sites.

Tests need to be fixed.

chadmandoo’s picture

I 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.

  • nicksanta authored a27951f on 8.x-1.x
    Issue #3167106 by kirkkala: Deprecated function User::getUsername (#39...
nicksanta’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.