Answer the question
In order to leave comments, you need to log in
Laravel how to log out a user during authorization?
I want to make it so that when the user logs in, he is thrown out of all other devices.
public function login(Request $request) {
// auth()->logout();
Auth::logout();
$phone = $request->phone;
$user = User::where('phone', $phone)->first();
if ($user) {
Auth::login($user, true);
return redirect()->route('catalog.index');
}
else {
return redirect()->back();
}
}
Answer the question
In order to leave comments, you need to log in
you need to authorize the user later:
Auth::logoutOtherDevices('password');
https://laravel.com/api/9.x/Illuminate/Support/Fac...
public function login(Request $request)
{
$phone = $request->phone;
$user = User::where('phone', $phone)->first();
if ($user) {
Auth::login($user, true);
Auth::logoutOtherDevices($request->password);
return redirect()->route('catalog.index');
}
else {
return redirect()->back();
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question