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

[5.4] Use route() helper instead of url() in Auth #17718

Merged
merged 2 commits into from
Feb 1, 2017

Conversation

kslimani
Copy link
Contributor

@kslimani kslimani commented Feb 1, 2017

Theses changes ease adding a prefix to Auth routes. For example :

/* routes/web.php */
Route::group(['prefix' => 'admin'], function(){
    Auth::routes();
});

I added a route name for "POST password/email", thought i am not sure about the name : password.email. (in router.php line 1007)

Should satisfy internal issue 307.

@taylorotwell taylorotwell merged commit 44fe5e0 into laravel:5.4 Feb 1, 2017
@kslimani kslimani deleted the auth-use-route-names branch February 1, 2017 16:28
@jondavidjohn
Copy link

Unfortunately this prevents people from defining their own naming scheme for the auth routes,

For example...

Route::group(['prefix' => 'admin', 'as' => 'admin.'], function(){
    Auth::routes();
});

This ends up being a breaking change (5.4) for people that had previously namespaced (or self defined) these route names.

@juukie
Copy link
Contributor

juukie commented Dec 16, 2017

Yeah @jondavidjohn is correct. In that case the only option is to copy the lines from Router::auth() and add them manually to your route file.

Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('login', 'Auth\LoginController@login');
Route::post('logout', 'Auth\LoginController@logout')->name('logout');

// Registration Routes...
Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
Route::post('register', 'Auth\RegisterController@register');

// Password Reset Routes...
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
Route::post('password/reset', 'Auth\ResetPasswordController@reset');

Since the routes are now named, you don't have to change urls in the views, so that's an advantage.

taylorotwell pushed a commit that referenced this pull request Apr 25, 2018
The reset.stub is using the GET named route (password.request) for the POST password/reset request (changed in #17718). Incorrectly using a named route from another route is confusing and could lead to unexpected results.
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.

4 participants