沃梦达 / 编程问答 / php问题 / 正文

Laravel 5.4 禁用注册路由

Laravel 5.4 Disable Register Route(Laravel 5.4 禁用注册路由)

本文介绍了Laravel 5.4 禁用注册路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试禁用在 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();

这是这组路线的捷径:

// 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');

因此,您可以用路由列表替换第一个,并注释掉您的应用程序中不需要的任何路由.

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() 函数调用添加一个参数以禁用注册路由:

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', 'AuthVerificationController@show')->name('verification.notice');
Route::get('email/verify/{id}', 'AuthVerificationController@verify')->name('verification.verify');
Route::get('email/resend', 'AuthVerificationController@resend')->name('verification.resend');

顺便说一句,您还可以禁用 Password ResetEmail Verification 路由:

BTW you can also disable Password Reset and Email Verification routes:

Auth::routes(['reset' => false, 'verify' => false]);

这篇关于Laravel 5.4 禁用注册路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Laravel 5.4 禁用注册路由

基础教程推荐