I need help with this. i successfully set up multi auth in laravel using JWT-Auth
In login functions I put this links And its work perfect.
Config::set('jwt.user', 'App\Models\User');
Config::set('auth.providers.users.model', \App\Models\User::class);
But in Logout function i put same line but its not working for logout function. its saying not found User model. here is the logout function.
public function logout(Request $request)
{
$this->validate($request, ['token' => 'required']);
try {
//Set Multi Auth Configs
Config::set('jwt.user', 'App\Models\User');
Config::set('auth.providers.users.model', \App\Models\User::class);
JWTAuth::invalidate($request->input('token'));
return $this->sendResponse('','successfully logged out');
} catch (JWTException $e) {
// something went wrong whilst attempting to encode the token
return $this->sendError('Failed to logout, please try again.', '', 500);
}
}
is there any way i can fix this issue?. thank you
public function logout(Request $request) {
$this->validate($request, ['token' => 'required']);
try {
JWTAuth::invalidate($request->input('token'));
return response()->json(['success' => true]);
} catch (JWTException $e) {
return response()->json(['success' => false, 'error' => 'Failed to logout, please try again.'], 500);
}
}