瀏覽代碼

Fix an infinite loop when having expired token

Occasionally, after an authorisation token expires, the app would keep
looping between the login page and the previous page spamming the user
with 'Unauthorised' notifications.
This commit also fixes the project being reset after an unauthorised API
call.
Sergiu Miclea 8 年之前
父節點
當前提交
81fb42aec0
共有 2 個文件被更改,包括 1 次插入2 次删除
  1. 0 1
      src/sources/UserSource.js
  2. 1 1
      src/utils/ApiCaller.js

+ 0 - 1
src/sources/UserSource.js

@@ -134,7 +134,6 @@ class UserSource {
         resolve(data)
         resolve(data)
       }).catch(() => {
       }).catch(() => {
         cookie.remove('token')
         cookie.remove('token')
-        cookie.remove('projectId')
         Api.setDefaultHeader('X-Auth-Token', null)
         Api.setDefaultHeader('X-Auth-Token', null)
         reject()
         reject()
       })
       })

+ 1 - 1
src/utils/ApiCaller.js

@@ -94,7 +94,7 @@ class ApiCaller {
           }
           }
 
 
           if (error.response.status === 401 && window.location.hash !== loginUrl) {
           if (error.response.status === 401 && window.location.hash !== loginUrl) {
-            window.location.href = `/${loginUrl}`
+            window.location.href = '/'
           }
           }
 
 
           console.log(`%cError Response: ${axiosOptions.url}`, 'color: #D0021B', error.response)
           console.log(`%cError Response: ${axiosOptions.url}`, 'color: #D0021B', error.response)