diff --git a/middleware/auth.global.ts b/middleware/auth.global.ts index d6e5917a..c809bec3 100644 --- a/middleware/auth.global.ts +++ b/middleware/auth.global.ts @@ -19,7 +19,12 @@ export default defineNuxtRouteMiddleware(async (to) => { await profileStore.getStoredToken() if (isAuthenticated.value) { - await profileStore.getProfile(); + try { + await profileStore.getProfile(); + } catch (e) { + console.error(e); + return navigateTo('/login') + } } if (to.name !== 'login' && !isAuthenticated.value) { diff --git a/src/entities/monolog/mocks/index.ts b/src/entities/monolog/mocks/index.ts index 556a09e1..2ea23170 100644 --- a/src/entities/monolog/mocks/index.ts +++ b/src/entities/monolog/mocks/index.ts @@ -1,5 +1,7 @@ +import monologExtendedMock from './monolog-extended.json'; import monologMock from './monolog.json'; export { monologMock, + monologExtendedMock, } diff --git a/src/entities/monolog/mocks/monolog-extended.json b/src/entities/monolog/mocks/monolog-extended.json new file mode 100644 index 00000000..4544b5be --- /dev/null +++ b/src/entities/monolog/mocks/monolog-extended.json @@ -0,0 +1,30 @@ +{ + "uuid": "019059fe-9284-71fe-9e47-a392664a8c87", + "project": null, + "type": "monolog", + "payload": { + "channel": "application", + "context": { + "cool": "heck yeah", + "here": "where?" + }, + "datetime": "2024-06-27T15:59:34.201624+02:00", + "extra": { + "callType": null, + "class": null, + "file": "[REDACTED]", + "function": "[REDACTED]", + "http_method": "GET", + "instance": "[REDACTED]", + "ip": "[REDACTED]", + "line": 514, + "referrer": null, + "server": "[REDACTED]", + "url": "[REDACTED]" + }, + "level": 200, + "level_name": "INFO", + "message": "Hello world" + }, + "timestamp": 1719496774.2804 +} diff --git a/src/entities/monolog/ui/preview-card/preview-card.stories.ts b/src/entities/monolog/ui/preview-card/preview-card.stories.ts index 88c33072..cef6bd7f 100644 --- a/src/entities/monolog/ui/preview-card/preview-card.stories.ts +++ b/src/entities/monolog/ui/preview-card/preview-card.stories.ts @@ -1,6 +1,6 @@ import type { Meta, StoryObj } from "@storybook/vue3"; import { useMonolog } from "../../lib"; -import { monologMock } from '../../mocks' +import { monologMock, monologExtendedMock } from '../../mocks' import PreviewCard from './preview-card.vue'; const { normalizeMonologEvent } = useMonolog(); @@ -28,3 +28,9 @@ export const WithOrigin: StoryObj = { } } } + +export const ComplexObject: StoryObj = { + args: { + event: normalizeMonologEvent(monologExtendedMock), + } +} diff --git a/src/entities/monolog/ui/preview-card/preview-card.vue b/src/entities/monolog/ui/preview-card/preview-card.vue index 17ea41dc..d1189840 100644 --- a/src/entities/monolog/ui/preview-card/preview-card.vue +++ b/src/entities/monolog/ui/preview-card/preview-card.vue @@ -45,10 +45,9 @@ const toggleView = () => { /> diff --git a/src/shared/stores/profile/profile-store.ts b/src/shared/stores/profile/profile-store.ts index e15352cf..62fe9cd1 100644 --- a/src/shared/stores/profile/profile-store.ts +++ b/src/shared/stores/profile/profile-store.ts @@ -1,5 +1,4 @@ import { defineStore } from "pinia"; -import {navigateTo} from "#app"; // eslint-disable-line @conarti/feature-sliced/layers-slices import {REST_API_URL} from "../../lib/io/constants"; import type {TProfile} from "../../types"; import {getStoredToken, removeStoredToken, setStoredToken} from "./local-storage-actions"; @@ -32,12 +31,11 @@ export const useProfileStore = defineStore("profileStore", { // TODO: add toast to show error console.error('Auth Error', response.status, response.statusText) - navigateTo('/login') + return new Error('Auth Error') } - return response + return response.json() }) - .then((response) => response.json()) .catch((e) => { console.error(e);