Modify existing Authorization module (email to username)

后端 未结 5 1648
灰色年华
灰色年华 2020-11-29 09:38

I would like to modify the existing Authorization module provided by Laravel 5, instead of asking for the email it will ask for the username field

5条回答
  •  -上瘾入骨i
    2020-11-29 10:18

    in controllers\auth\logincontroller add this

     protected $username = 'user_name';//user_name field name
    

    then go to Illuminate\Foundation\Auth\AuthenticatesUsers and change

     public function username()
        {
             return 'email';//change this with "return $this->username;"
        }
    

    with this method You can have different log in type in different controller for example in another controller controllers\admin_auth\logincontroller

    protected $username = 'phone_number';
    

提交回复
热议问题