This doesn't work:

$user = User::find()->email("[email protected]")->one();
if ($user->authenticate("myClearTextPassword")) {
  // This is never true, so you never get here

Is this method broken, or am I using it incorrectly?

  • What does $user->authError return after you call the authenticate method?
    – Brad Bell
    Dec 21, 2020 at 1:28
  • Thanks for taking a look @BradBell. I get invalid_credentials, even when the password is correct. Dec 21, 2020 at 5:57
  • Is the user in a soft-deleted state? Or do you have craftcms.com/docs/3.x/config/… set to true?
    – Brad Bell
    Dec 23, 2020 at 20:32
  • @BradBell I can confirm that this is not working still in 3.7.38. preventUserEnumeration has not been set and should be defaulted to false.
    – biko
    Apr 22, 2022 at 4:41


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.