@nitra/vite-boot 3.4.0 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/token.js +21 -16
package/package.json
CHANGED
package/src/token.js
CHANGED
|
@@ -84,22 +84,27 @@ export async function refreshToken() {
|
|
|
84
84
|
|
|
85
85
|
const result = await response.json()
|
|
86
86
|
|
|
87
|
-
// Якщо успішно отримали токен
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
87
|
+
// Якщо НЕ успішно отримали токен
|
|
88
|
+
if (!result.token) {
|
|
89
|
+
// cleanToken()
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const check = checkToken(result.token)
|
|
94
|
+
if (check.result !== 'ok') {
|
|
95
|
+
// cleanToken()
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Якщо запущений аполо
|
|
100
|
+
// допускаємо що ми всередині прикладення
|
|
101
|
+
if (apolloClient) {
|
|
102
|
+
setUser(check.decoded)
|
|
103
|
+
|
|
104
|
+
// перезавантажуємо щоб він вступив в дію
|
|
105
|
+
wsClient.restart()
|
|
106
|
+
} else {
|
|
107
|
+
await defaultLogin(check.decoded, result.token)
|
|
103
108
|
}
|
|
104
109
|
} catch (error) {
|
|
105
110
|
console.error('Error:', error)
|