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

Fixed missing validation error for password #225

Closed
wants to merge 1 commit into from

Conversation

akulmehta
Copy link

When a user tries to login and enters the wrong password, the authentication fails and the sendFailedLoginResponse is triggered. Previously this function only throws a ValidationException with the email field, causing the error message of auth.failed which in default Laravel app is "These credentials do not match our records." to only appear below the email input field, and does not show any invalidity in the UI in the password field, even if the password field is what was incorrect (I observed this when using Bootstrap scaffolding). As a result this would make the user feel that the incorrect input was the email address rather than the password.

This PR is an attempt to fix this issue by adding the password field to the ValidationException. By doing this, the error bag contains the password field and appropriate invalid message and UI elements are shown.

Tests are edited accordingly.

@akulmehta
Copy link
Author

Note - I chose to use the same error i.e. auth.failed as this is already part of core Laravel. But maybe the core Laravel message for auth.failed should read "One or more of these credentials do not match our records.". I am not sure how errors are handled by other authentication packages (Fortify) so not sure if I should touch that. But this is easy to customize by editing the language file too.

@taylorotwell
Copy link
Member

It's fine as is.

@akulmehta
Copy link
Author

@taylorotwell Please reconsider. If the user enters the wrong password, the email field shows the error. The user ends up thinking that their email address is wrong.

@akulmehta
Copy link
Author

This is what the UI looks like when the password is wrong:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants