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

[1.x] Allow the expected email address request variable to be changed #28

Merged
merged 3 commits into from
Sep 14, 2020

Conversation

adear11
Copy link
Contributor

@adear11 adear11 commented Sep 11, 2020

This pull requests gives the ability to change the expected name of the variable in the request that holds the email address when making requests for forgotten passwords and when setting a new password. As it is implemented currently, the request variable name email is hard coded into the controllers for both requesting a password reset link and for setting the new password after visiting the reset link. This pull request adds a new config option, similar to the username option that is currently there, to allow for changing the expected variable name.

The implementation maintains the email name as a default value so that any existing applications should not experience any BC breaks.

The ability to set the expected name of the email address request variable via a config value makes it much easier to integrate a new Laravel application that uses Fortify into an existing system that already has an established database schema that cannot be changed. Without the ability to change that hard coded value via config value, it appears as though the only solution to this problem would be to re-implement all of the password reset logic and controllers simply to change the one request variable.

…hat contains the email address when making forgot password and password reset requests.
config/fortify.php Outdated Show resolved Hide resolved
src/Fortify.php Outdated Show resolved Hide resolved
…mail' to match other apps and packages in the eco system.
@driesvints driesvints changed the title Allow the expected email address request variable to be changed [1.x] Allow the expected email address request variable to be changed Sep 14, 2020
@driesvints
Copy link
Member

@adear11 Taylor will review your PR once he's ready.

@adear11
Copy link
Contributor Author

adear11 commented Sep 14, 2020

@taylorotwell

I got an email that you commented on this PR, but I can't find your comment. So I'm replying here rather than directly to your comment.

I would have expected that what the POST variable was named would not matter. However, that does not appear to be the case.

Further down the call stack, the retrieveByCredentials method of Illuminate\Auth\EloquentUserProvider uses the key names to build the query to retrieve the user by email address. This ultimately means that the name of the email address POST variable has to match the database column.

The same thing is true for src/Http/Controllers/NewPasswordController since it uses the same retrieveByCredentials method call.

@taylorotwell taylorotwell merged commit 7dc23ed into laravel:1.x Sep 14, 2020
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.

3 participants