Modify existing Authorization module (email to username)

后端 未结 5 1647
灰色年华
灰色年华 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条回答
  •  自闭症患者
    2020-11-29 10:12

    Laravel search the variable $username in the file :

    Illuminate\Foundation\Auth\AuthenticatesUsers

    public function loginUsername() {
        return property_exists($this, 'username') ? $this->username : 'email';
    }
    

    As you can see, by default it will be named as 'email'.

    However you can override it in your AuthController by adding :

    protected $username = 'username';
    

提交回复
热议问题