I have a guard called "Representante" and need to verify if there is anyone logged in the web.php file. When i verify, it returns false but in the LoginController returns true.
im making a login system, did not use Laravel Auth because my users and password are stored in differents tables and didnt wanted to bother changing the auth, make one from 0 gonna be more fast
web.php
Route::get('/', function () {
// Verifica se existe alguém logado, se tiver mostra os pedidos,
// Se não mostra o login.
dd(Auth::guard('representante')->check());
//Here returns FALSE
if( Auth::guard('representante')->check() || Auth::check() ) {
return redirect()->route('pedidos.index');
} else {
return view('login');
}
})->name('login');
Login Controller
if (Hash::check($pass, $db_pass->sv_senha)) {
switch ($type) {
case 1:
Auth::login($db_user);
break;
case 2:
Auth::guard('representante')->login($db_user);
dd(Auth::guard('representante')->user());
//Here returns TRUE
break;
}
return redirect()->route('pedidos.index');
} else {
return redirect()->back()->withErrors(['senha' => 'Senha Incorreta'])->withInput();
}