从Laravel身份验证中排除路由 [英] Exclude route from Laravel authentication
问题描述
运行php artisan make:auth
后,所有必需的路由都在route.php
文件中,但是是否可以删除一个(我要删除注册路由)?
After running php artisan make:auth
all the required routes are in the route.php
file, but is it possible to remove one (I want to remove the register route)?
当前我有
Route::group(['middleware' => 'web'], function () {
Route::auth();
});
我知道Route::auth()
是添加所有路由的快捷方式.
我应该自己指定路线而不是使用快捷方式吗?
I know that Route::auth()
is a shortcut to add all the routes.
Should I specify the routes myself instead of using the shortcut?
推荐答案
Unfortunately you can't exclude register with the current implementation of Route::auth()
.
您必须手动指定所有路线,所以
You would have to specify all the routes manually so
// Authentication Routes...
$this->get('login', 'Auth\AuthController@showLoginForm');
$this->post('login', 'Auth\AuthController@login');
$this->get('logout', 'Auth\AuthController@logout');
// Password Reset Routes...
$this->get('password/reset/{token?}', 'Auth\PasswordController@showResetForm');
$this->post('password/email', 'Auth\PasswordController@sendResetLinkEmail');
$this->post('password/reset', 'Auth\PasswordController@reset');
我认为这是一件很平常的事情,如果auth
方法中有一个参数可以说不注册就可以,那么您可以向项目提交请求请求.
I think this is a fairly common thing to want to do it would be nice if there was a parameter to the auth
method to say without register maybe you could submit a pull-request to the project.
这篇关于从Laravel身份验证中排除路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!