This is an automated email from the ASF dual-hosted git repository.

mintsweet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 73739e641 fix(configui): return to login only when invalid token to 
missing auth header (#5014)
73739e641 is described below

commit 73739e6416a66e6fefa2889d7457c9c84d7ea34a
Author: Warren Chen <[email protected]>
AuthorDate: Mon Apr 24 13:35:05 2023 +0800

    fix(configui): return to login only when invalid token to missing auth 
header (#5014)
---
 config-ui/src/utils/request.ts | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/config-ui/src/utils/request.ts b/config-ui/src/utils/request.ts
index 2fb8ba59b..d0b31ffa8 100644
--- a/config-ui/src/utils/request.ts
+++ b/config-ui/src/utils/request.ts
@@ -51,13 +51,18 @@ export const request = (path: string, config?: 
ReuqestConfig) => {
   } else {
     params.data = data;
   }
+  const missingAuthHeader = 'Authorization header is missing';
+  const invalidToken = 'Invalid token';
 
   instance.interceptors.response.use(
     (response) => response,
     (error) => {
       if (error.response && error.response.status === 401) {
-        toast.error('Please log in first');
-        history.push('/login');
+        // only handle when data contains missingAuthHeader or invalidToken
+        if (error.response.data.includes(missingAuthHeader) || 
error.response.data.includes(invalidToken)) {
+          toast.error('Please login first');
+          history.push('/login');
+        }
       }
     },
   );

Reply via email to