Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Gracefully handle null passwords when verifying credentials #53156

Merged
merged 2 commits into from
Oct 14, 2024

Conversation

gbradley
Copy link
Contributor

@gbradley gbradley commented Oct 14, 2024

Currently, both the EloquentUserProvider and DatabaseUserProvider classes throw an exception if the user's getAuthPassword() method returns null. If the user does not have a password set, and the configured hasher follows the default behaviour of verifying hashes, then a RuntimeException is thrown e.g.

This password does not use the Bcrypt algorithm

While technically true, this results in an end user being shown a 500 error when attempting to sign into an account where an initial password has not been set. This can happen frequently in apps where accounts are created by other users rather than by self-registration.

This PR assumes that if a user's password is null, the validateCredentials methods should handle this gracefully and simply return false rather than throwing an exception, resulting in a better experience for the end user.

@taylorotwell taylorotwell merged commit 231091c into laravel:11.x Oct 14, 2024
31 checks passed
timacdonald pushed a commit to timacdonald/framework that referenced this pull request Oct 15, 2024
…aravel#53156)

* Gracefully handle null passwords when verifying credentials

* Removed  method calls in tests.

---------

Co-authored-by: Graham Bradley <gbradley@onlyexcel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants