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] Ensures route password.confirm is defined when not using views #368

Merged

Conversation

Frozire
Copy link
Contributor

@Frozire Frozire commented Mar 4, 2022

This fixes #367

If you implement fortify without views, you have to hardcode the password.confirm route because no name is defined on the post route.

fortify/routes/routes.php

Lines 120 to 121 in b2de125

Route::post('/user/confirm-password', [ConfirmablePasswordController::class, 'store'])
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')]);

If you have views enabled ($enableViews = true), you are saved because a get route is defined with the same route.

fortify/routes/routes.php

Lines 110 to 114 in b2de125

if ($enableViews) {
Route::get('/user/confirm-password', [ConfirmablePasswordController::class, 'show'])
->middleware([config('fortify.auth_middleware', 'auth').':'.config('fortify.guard')])
->name('password.confirm');
}

Currently, this forces people using Fortify with a SPA/custom views ($enableViews = false), to hardcode the password.confirm route.

While this might not be the prettiest fix, it is a fix that will not cause breaking changes for those already using the package.

@driesvints driesvints changed the title Ensures route password.confirm is defined when not using views [1.x] Ensures route password.confirm is defined when not using views Mar 4, 2022
@driesvints
Copy link
Member

Another easier solution is to just name the post route and remove it from the get route.

@Frozire
Copy link
Contributor Author

Frozire commented Mar 4, 2022

Another easier solution is to just name the post route and remove it from the get route.

I've changed this PR according to your suggestions.

@taylorotwell taylorotwell merged commit 35c44f3 into laravel:1.x Mar 4, 2022
@Frozire Frozire deleted the define-password-confirm-route-always branch March 5, 2022 08:25
@bessone
Copy link

bessone commented Sep 15, 2022

with this modification I get an error with the Laravel Breadcrumbs project (https://github.com/diglactic/laravel-breadcrumbs), all the routes in GET must have a name to be used with the breadcrumbs, having moved the name from GET to POST there is no more way to make it work.

PR to correct use without views has created the problem for those who use views (with breadcrumbs)

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.

Missing route name for password.confirm without enabled views
4 participants