From db234bd01bcb9e47aefeb4a25a9ca4268f7f846c Mon Sep 17 00:00:00 2001 From: silverpill Date: Mon, 3 Jan 2022 16:38:26 +0000 Subject: [PATCH] Remove token from local storage on auth failures --- src/store/user.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/store/user.ts b/src/store/user.ts index 651e2eb..52c152d 100644 --- a/src/store/user.ts +++ b/src/store/user.ts @@ -42,6 +42,10 @@ export function useCurrentUser() { if (token) { authToken.value = token currentUser.value = await getCurrentUser(token) + if (currentUser.value === null) { + // Failed to get current user, removing invalid token + setAuthToken(null) + } } isAuthChecked.value = true }