Hello, I am developing an application in Laravel 5.2. * and need to implement a login system by username or login, does anyone have any idea how to configure or do this type of method?
Hello, I am developing an application in Laravel 5.2. * and need to implement a login system by username or login, does anyone have any idea how to configure or do this type of method?
You can create a new login method as follows:
public function authenticate( Request $request )
{
$password = bcrypt( $request->input( 'password' ) );
$login = $request->input( 'login' ); // Email ou username
if ( Auth::attempt( ['email' => $login, 'password' => $password] ) || Auth::attempt( ['username' => $login, 'password' => $password] ) ) {
// Authentication passed...
return redirect()->intended('dashboard');
}
}
Illuminate\Foundation\Auth\AuthenticatesUsers
Change the variable by the field you want to authenticate
protected $username = 'username';