Custom authentication with CPF and E-MAIL

4

I'm thinking of a way to authenticate users using email and the CPF of it, so far I have not found a way to do it, does anyone have a suggestion?

public function auth(Request $request) {
    $credenciais = $request->only('cli_email', 'cli_cpf');
}
    
asked by anonymous 22.08.2016 / 21:16

1 answer

4

The Laravel Framework has a form of authentication with the class User instance, so you can check other relevant data for your purpose to access the system, for example:

>
$user = User::where('cpf', $cpf)->where('email', $email)->first();
if ($user) // se verdade existe um usuário com essas informações
{
    Auth::login($user); //efetuando a operação de autenticação
}

But, would not it be a security flaw ?, because it is easy to find out the CPF and E-mail of some user, the password should also be informed by be a data of each user.

    
06.09.2016 / 22:50