🐛 Fix on pulling user data when login
This commit is contained in:
parent
6f4ac1a0e6
commit
0e64557800
@ -3,11 +3,11 @@ import { ref } from "vue"
|
|||||||
import { solarFetch } from "~/utils/request"
|
import { solarFetch } from "~/utils/request"
|
||||||
|
|
||||||
export function useAtk() {
|
export function useAtk() {
|
||||||
return useCookie("__hydrogen_atk", { watch: "shallow" })
|
return useCookie("__hydrogen_atk", { watch: "shallow", maxAge: 31556952000 })
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useRtk() {
|
export function useRtk() {
|
||||||
return useCookie("__hydrogen_rtk", { watch: "shallow" })
|
return useCookie("__hydrogen_rtk", { watch: "shallow", maxAge: 31556952000 })
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useLoggedInState() {
|
export function useLoggedInState() {
|
||||||
@ -74,13 +74,16 @@ export const useUserinfo = defineStore("userinfo", () => {
|
|||||||
|
|
||||||
if (!useLoggedInState().value) {
|
if (!useLoggedInState().value) {
|
||||||
fetchCompleter.complete(true)
|
fetchCompleter.complete(true)
|
||||||
|
fetchCompleter = null
|
||||||
isReady.value = true
|
isReady.value = true
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await solarFetch("/cgi/id/users/me")
|
const res = await solarFetch("/cgi/id/users/me")
|
||||||
|
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
fetchCompleter.complete(true)
|
fetchCompleter.complete(true)
|
||||||
|
fetchCompleter = null
|
||||||
isReady.value = true
|
isReady.value = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -91,6 +94,7 @@ export const useUserinfo = defineStore("userinfo", () => {
|
|||||||
isReady.value = true
|
isReady.value = true
|
||||||
userinfo.value = data
|
userinfo.value = data
|
||||||
fetchCompleter.complete(true)
|
fetchCompleter.complete(true)
|
||||||
|
fetchCompleter = null
|
||||||
}
|
}
|
||||||
|
|
||||||
return { userinfo, lastRefreshedAt, isLoggedIn, isReady, fetchCompleter, setTokenSet, getAtk, readProfiles }
|
return { userinfo, lastRefreshedAt, isLoggedIn, isReady, fetchCompleter, setTokenSet, getAtk, readProfiles }
|
||||||
|
Loading…
Reference in New Issue
Block a user