Can the email field used at login to authenticate to the users table in Laravel 5.3 be overwritten to use the username field like we did in prior version calling this protected method in App/Http/Controllers/Auth/LoginController.php
/**
* username or email field.
*
* @var string
*/
protected $username = 'username';
Method needing to be changed is in file vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php
/**
* Get the login username to be used by the controller.
*
* @return string
*/
public function username()
{
return 'email';
}
This used to be the method in Laravel 5.2 that would allow the override
public function loginUsername()
{
return property_exists($this, 'username') ? $this->username : 'email';
}
Any Ideas?
I don't find similar code in 5.3, but yes, it was in 5.2.
Finally, I override AuthenticatesUsers trait to my own.
Simply override the AuthenticatesUsers trait in your auth controller.
Was able to override the email field to username the by putting the following in Auth/LoginController.php
/**
* Get the login username to be used by the controller.
*
* @return string
*/
public function username()
{
return 'username';
}
Most helpful comment
Was able to override the email field to username the by putting the following in Auth/LoginController.php