0
In case when logging in with Return view, it loads the home view above the /login url:
public function logon(Request $request){
$dados = $request->all();
$usuario = Usuario::where('email', $dados['email'])->first();
if(Auth::check() || ($usuario && Hash::check($dados['senha'], $usuario->senha))){
Auth::login($usuario, true);
return view('welcome');
}else{
return view('login');
}
}
The question is whether it is a common and valid practice to use redirect, so that when logging in it changes Uri to / again:
public function logon(Request $request){
$dados = $request->all();
$usuario = Usuario::where('email', $dados['email'])->first();
if(Auth::check() || ($usuario && Hash::check($dados['senha'], $usuario->senha))){
Auth::login($usuario, true);
return redirect()->route('home');
}else{
return redirect()->route('login');
}
}
It is correct to carry out the execution in this way?