Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify existing Authorization module (email to username)

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 in the database.

like image 333
Rene Padillo Avatar asked Feb 18 '15 13:02

Rene Padillo


1 Answers

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';
like image 172
Alexandre Chopin Avatar answered Sep 18 '22 11:09

Alexandre Chopin