Laravel 5.4禁用注册路由 [英] Laravel 5.4 Disable Register Route
问题描述
我试图在Laravel 5.4中运行的应用程序上禁用注册路由.
I am trying to disable the register route on my application which is running in Laravel 5.4.
在我的路线文件中,我只有
In my routes file, I have only the
Auth::routes();
有什么方法可以禁用注册路由吗?
Is there any way to disable the register routes?
推荐答案
code
:
Auth::routes();
它是此路线集合的捷径:
its a shorcut for this collection of routes:
// Authentication Routes...
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');
因此,您可以用路由列表替换第一个路由,并注释掉应用程序中不需要的任何路由.
So you can substitute the first with the list of routes and comment out any route you don't want in your application.
为laravel version => 5.7
Edit for laravel version => 5.7
在较新的版本中,您可以在Auth::routes()
函数调用中添加参数以禁用寄存器路由:
In newer versions you can add a parameter to the Auth::routes()
function call to disable the register routes:
Auth::routes(['register' => false]);
已添加电子邮件验证路由:
The email verification routes were added:
Route::get('email/verify', 'Auth\VerificationController@show')->name('verification.notice');
Route::get('email/verify/{id}', 'Auth\VerificationController@verify')->name('verification.verify');
Route::get('email/resend', 'Auth\VerificationController@resend')->name('verification.resend');
顺便说一句,您还可以禁用Password Reset
和Email Verification
路由:
BTW you can also disable Password Reset
and Email Verification
routes:
Auth::routes(['reset' => false, 'verify' => false]);
这篇关于Laravel 5.4禁用注册路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!