From cce967e5030ee0e2bd4d72a579bcc29941a2bc43 Mon Sep 17 00:00:00 2001
From: Matthieu Petit
Date: Tue, 26 Dec 2023 15:59:19 +0100
Subject: [PATCH] fix(auth): check status and message on 401
---
src/services/interceptors.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/services/interceptors.ts b/src/services/interceptors.ts
index ca8bcb3..ca40d37 100644
--- a/src/services/interceptors.ts
+++ b/src/services/interceptors.ts
@@ -87,7 +87,8 @@ const createHttpInterceptors = (httpInstance: AxiosInstance) => {
const content = axiosError.response?.data as any;
const parsedError =
typeof content?.text === 'function' ? JSON.parse(await content.text()) : content;
- const isTokenExpired = parsedError.code === 'EXPIRED_ACCESS_TOKEN';
+ // const isTokenExpired = parsedError.reason === 'EXPIRED_ACCESS_TOKEN';
+ const isTokenExpired = parsedError.code === 401 && parsedError.message === 'Unauthorized'; // until the backend send a proper error code
if (isTokenExpired) {
// should fetch another access token and retry
const authStore = useAuthStore();