LARAVEL Login by email or username [closed]

1

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?

    
asked by anonymous 11.06.2017 / 19:08

2 answers

1

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');
    }
}
    
12.06.2017 / 15:31
1
Illuminate\Foundation\Auth\AuthenticatesUsers

Change the variable by the field you want to authenticate

protected $username = 'username';
    
12.06.2017 / 01:28