更新时间:2023-12-03 10:17:22
如果您为用户和客户端都有一个令牌表,则可以这样做...对于注销,您只需从令牌表中删除令牌即可. ..简单方法=>
If you have one token table for both user and client then you can do like this...For logout you just have to delete the token from token table... Simple way =>
public function logOut($id) {
if (Auth::check()) {
$user = Auth::user();
Token::where('user_id',$user->id)
->where(external identification)
->delete();
$response = [
'status' => true,
'message' => 'Successfully Logged Out',
];
return response()->json($response); //@ sending response
} else {
$response = [
'status' => false,
'message' => 'Bad Request!',
];
return response()->json($response); //@ sending response
}
}