@nitra/vite-boot 3.3.1 → 3.3.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/login.js +5 -4
- package/src/token.js +1 -1
package/package.json
CHANGED
package/src/login.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { checkToken
|
|
1
|
+
import { checkToken } from './token.js'
|
|
2
2
|
import { setUser } from './user.js'
|
|
3
3
|
// import { router } from './router.js'
|
|
4
4
|
// Використовуємо глобальну версію
|
|
@@ -13,7 +13,7 @@ export async function autoLogin(token) {
|
|
|
13
13
|
if (token) {
|
|
14
14
|
const check = checkToken(token)
|
|
15
15
|
if (check.result === 'ok') {
|
|
16
|
-
await defaultLogin(check.decoded)
|
|
16
|
+
await defaultLogin(check.decoded, token)
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -22,11 +22,12 @@ export async function autoLogin(token) {
|
|
|
22
22
|
* Вхід аоб на попередню або на кореневу сторінку
|
|
23
23
|
*
|
|
24
24
|
* @param {Object} decoded
|
|
25
|
+
* @param {String} raw? - необов'язково, але потрібно якщо використовується localStorage
|
|
25
26
|
*/
|
|
26
|
-
export async function defaultLogin(decoded) {
|
|
27
|
+
export async function defaultLogin(decoded, raw = null) {
|
|
27
28
|
// Якщо задано що токен з localStorage
|
|
28
29
|
if (import.meta.env.VITE_TOKEN_STORAGE) {
|
|
29
|
-
return localStorage.setItem(import.meta.env.
|
|
30
|
+
return localStorage.setItem(import.meta.env.VITE_TOKEN_STORAGE, raw)
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
setUser(decoded)
|
package/src/token.js
CHANGED