@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/token.js +21 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitra/vite-boot",
3
- "version": "3.4.0",
3
+ "version": "3.4.2",
4
4
  "description": "Vite boot",
5
5
  "type": "module",
6
6
  "exports": {
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
- if (result.token) {
90
- const check = checkToken(result.token)
91
- if (check.result === 'ok') {
92
- // Якщо запущений аполо
93
- // допускаємо що ми всередині прикладення
94
- if (apolloClient) {
95
- setUser(check.decoded)
96
-
97
- // перезавантажуємо щоб він вступив в дію
98
- wsClient.restart()
99
- } else {
100
- await defaultLogin(check.decoded, result.token)
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)