如何在Laravel中禁用注册新用户 [英] How to disable registration new users in Laravel
本文介绍了如何在Laravel中禁用注册新用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Laravel(v5).
我需要一个用户,我已经注册了. 现在,我想为新用户禁用注册. 当然,我需要登录表单才能工作.
我该怎么做?
解决方案
Laravel 5.7引入了以下功能:
Auth::routes(['register' => false]);
此处当前可能的选项是:
Auth::routes([
'register' => false, // Registration Routes...
'reset' => false, // Password Reset Routes...
'verify' => false, // Email Verification Routes...
]);
对于较早的Laravel版本,只需在
中覆盖showRegistrationForm()
和register()
方法
-
AuthController
适用于Laravel 5.0-5.4 -
Auth/RegisterController.php
适用于Laravel 5.5
public function showRegistrationForm()
{
return redirect('login');
}
public function register()
{
}
I'm using Laravel (v5).
I need one user and I've already registered that. Now I want to disable registration for new users. Of course, I need the login form to work.
How can I do that?
解决方案
Laravel 5.7 introduced the following functionality:
Auth::routes(['register' => false]);
The currently possible options here are:
Auth::routes([
'register' => false, // Registration Routes...
'reset' => false, // Password Reset Routes...
'verify' => false, // Email Verification Routes...
]);
For older Laravel versions just override showRegistrationForm()
and register()
methods in
AuthController
for Laravel 5.0 - 5.4Auth/RegisterController.php
for Laravel 5.5
public function showRegistrationForm()
{
return redirect('login');
}
public function register()
{
}
这篇关于如何在Laravel中禁用注册新用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文