I tried several ways to login, the one that works is Auth::login($user);
, but he doesn't stay logged in, he goes back to the login page.
Login Controller:
public function validateCode(Request $request)
{
$email = $request->email;
// Get user
$user = User::where('email', $email)->first();
if ($user->count() > 0) {
$validateCode = $request->input('validateCode');
// Check the codes
if ($validateCode == $user['codConfirm']) {
Auth::login($user, true);
if(Auth::check())
return redirect()->route('home');
else{
dd('else');
return redirect()->action('Auth\LoginController@index', ['validator' => ['Não foi possível fazer o login']]);
}
} else {
return view('confirmar-usuario', ['email' => $email]);
}
}
else {
flash('Usuário inválido')->error();
return view('login');
}
}
I will answer my own question as I found out and the question I had thought about has been deleted. So I'm posting here to help someone.