Feb 8, 2023
0
Level 1
logout destroy
Hello,
My logout is not 100%, it seems that sometimes when I logout, it refreshes and goes back to where it was instead of logging out, it doesn't seem to delete the token.
class DestroyActiveBearerTokenController extends Controller
{
public function __invoke(): JsonResponse
{
[$id, $token] = explode('|', request()->bearerToken(), 2);
// Get token
$instance = PersonalAccessToken::findOrFail($id);
// Check the correct token
if (hash_equals($instance->token, hash('sha256', $token))) {
// Delete token
$instance->delete();
return response()->json([
'type' => 'success',
'message' => 'You were successfully logged out',
]);
}
return response()->json([
'type' => 'error',
'message' => 'You are not authorized',
], 401);
}
}
In vue I use this
logOut() {
this.$store.dispatch('logOut')
},
Thank you
Please or to participate in this conversation.