問(wèn)題描述
我正在嘗試禁用在 Laravel 5.4 中運(yùn)行的應(yīng)用程序上的注冊(cè)路由.
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();
有什么辦法可以禁用注冊(cè)路由嗎?
Is there any way to disable the register routes?
推薦答案
code
:
Auth::routes();
這是這組路線的捷徑:
// Authentication Routes...
Route::get('login', 'AuthLoginController@showLoginForm')->name('login');
Route::post('login', 'AuthLoginController@login');
Route::post('logout', 'AuthLoginController@logout')->name('logout');
// Registration Routes...
Route::get('register', 'AuthRegisterController@showRegistrationForm')->name('register');
Route::post('register', 'AuthRegisterController@register');
// Password Reset Routes...
Route::get('password/reset', 'AuthForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('password/email', 'AuthForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('password/reset/{token}', 'AuthResetPasswordController@showResetForm')->name('password.reset');
Route::post('password/reset', 'AuthResetPasswordController@reset');
因此,您可以用路由列表替換第一個(gè),并注釋掉您的應(yīng)用程序中不需要的任何路由.
So you can substitute the first with the list of routes and comment out any route you don't want in your application.
編輯 laravel 版本 =>5.7
在較新的版本中,您可以向 Auth::routes()
函數(shù)調(diào)用添加一個(gè)參數(shù)以禁用注冊(cè)路由:
In newer versions you can add a parameter to the Auth::routes()
function call to disable the register routes:
Auth::routes(['register' => false]);
添加了電子郵件驗(yàn)證路徑:
The email verification routes were added:
Route::get('email/verify', 'AuthVerificationController@show')->name('verification.notice');
Route::get('email/verify/{id}', 'AuthVerificationController@verify')->name('verification.verify');
Route::get('email/resend', 'AuthVerificationController@resend')->name('verification.resend');
順便說(shuō)一句,您還可以禁用 Password Reset
和 Email Verification
路由:
BTW you can also disable Password Reset
and Email Verification
routes:
Auth::routes(['reset' => false, 'verify' => false]);
這篇關(guān)于Laravel 5.4 禁用注冊(cè)路由的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!