send login information to the bank for comparison

2

I'm developing a system with login and password, using laravel. The registration part was even easy:

public function salvar(){
    $usu_email = Request()->input('usu_email');
    $usu_senha = Request()->input('usu_senha');
    $usu_tipo = Request()->input('usu_tipo');

    DB::insert('INSERT INTO usr_usuario (usu_email, usu_senha, usu_tipo) VALUES (?, md5(?), ?)', array($usu_email, $usu_senha, $usu_tipo));

    return redirect() ->action('ProjetoController@inicio');
}

But as far as sending the information to the bank and comparing it, I'm a bit confused. In the database I have the following script that will make the comparison:

 select usu_codigo,usu_tipo 
 from usr_usuario
 where usu_email=:usu_email
 and usu_senha=md5(:usu_senha)

But I do not know how to do in my ProjectController.php to send the information. I think it's something like sending it to the bank on the registration side.

    
asked by anonymous 12.04.2018 / 21:49

1 answer

3

You can use the authentication that Laravel itself already makes available.

At the beginning of your controller, give use Auth; to use the Auth class within your controller.

public function authenticate()
{
    if ( Auth::attempt(['email' => $email, 'password' => bcrypt( $password ) ])) {
        // Autenticação autorizada...
    }
}
    
16.04.2018 / 14:23