How to disable registration new users in Laravel

后端 未结 27 2918
鱼传尺愫
鱼传尺愫 2020-12-07 10:34

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 wor

27条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 11:26

    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.4
    • Auth/RegisterController.php for Laravel 5.5
    public function showRegistrationForm()
    {
        return redirect('login');
    }
    
    public function register()
    {
    
    }
    

提交回复
热议问题