|
|
@@ -1,4 +1,3 @@
|
|
|
-import {defineNuxtPlugin, useCookie} from "nuxt/app";
|
|
|
import {useAccessProfileStore} from "~/stores/accessProfile";
|
|
|
import {useEntityManager} from "~/composables/data/useEntityManager";
|
|
|
import UnauthorizedError from "~/services/error/UnauthorizedError";
|
|
|
@@ -8,24 +7,28 @@ export default defineNuxtPlugin(async () => {
|
|
|
const redirectToLogout = useRedirectToLogout()
|
|
|
|
|
|
const bearer = useCookie('BEARER')
|
|
|
- const accessId = useCookie('AccessId')
|
|
|
+ let accessCookieId = useCookie('AccessId')
|
|
|
|
|
|
- const accessProfile = useAccessProfileStore()
|
|
|
+ console.log(accessCookieId.value, Number.isNaN(accessCookieId.value))
|
|
|
|
|
|
- if (accessId.value === null) {
|
|
|
+ if (accessCookieId.value === null || Number.isNaN(accessCookieId.value)) {
|
|
|
redirectToLogout()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ const accessId: number = parseInt(accessCookieId.value)
|
|
|
+
|
|
|
+ const accessProfile = useAccessProfileStore()
|
|
|
+
|
|
|
accessProfile.$patch({
|
|
|
bearer: bearer.value,
|
|
|
- id: parseInt(accessId.value)
|
|
|
+ id: accessId
|
|
|
})
|
|
|
|
|
|
const {em} = useEntityManager()
|
|
|
|
|
|
try {
|
|
|
- await em.refreshProfile(parseInt(accessId.value))
|
|
|
+ await em.refreshProfile(accessId)
|
|
|
} catch (error) {
|
|
|
if (error instanceof UnauthorizedError) {
|
|
|
redirectToLogout()
|