0
I have the function authenticate which checks whether the e-mail and password entered match those of the users table. The code is working, but after checking which email and password check, I redirect to the view logged. So far so good. But I would like this view not to be accessed directly. I would like to make it accessible only to those who are logged in. Can you understand that? Because if I access the direct url of this view, it accesses it. I want to restrict this.
public function autenticar(Request $request)
{
//Pego dados do formulário de login e armazeno na variavel $dados
$dados = $request->except('_token');
//Depois de armazenar na variavel dados, separo em $email e $password
$email = $dados['email'];
$password = $dados['password'];
//Faz a consulta e verifica se email digitado é igual email do banco
$query = $this->user->where('email', $email)->first();
//Verifica se o email existe
if (!$query)
{
return null;
}
//Verifica se a senha digitada é igual a senha hash do banco
if (Hash::check($password, $query->password))
{
return redirect()->route('logado');
}
else
{
return null;
}
It worked! Even so I will read the documentation more calmly. Thank you
– Barraviera