Laravel 5.4 Disable Register Route(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 Reset
和 Email Verification
路由:
BTW you can also disable Password Reset
and Email Verification
routes:
Auth::routes(['reset' => false, 'verify' => false]);
这篇关于Laravel 5.4 禁用注册路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Laravel 5.4 禁用注册路由
基础教程推荐
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- HTTP 与 FTP 上传 2021-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01