From c4e7eb81efc32fc218ab72d09eef69abce8588bb Mon Sep 17 00:00:00 2001 From: Zaxiure Date: Sat, 7 Sep 2024 23:34:37 +0200 Subject: [PATCH] Get token from cookies to prevent logging in on refresh. --- src/screens/Login.vue | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/screens/Login.vue b/src/screens/Login.vue index 16a122c..f1c51dd 100644 --- a/src/screens/Login.vue +++ b/src/screens/Login.vue @@ -33,6 +33,7 @@ import { login, register } from '@/services/authentication' import { useNotificationStore } from '@/stores/notifications' import { useGameStore } from '@/stores/game' import { useAssetStore } from '@/stores/assets' +import { useCookies } from '@vueuse/integrations/useCookies' const gameStore = useGameStore() const notifications = useNotificationStore() @@ -45,6 +46,13 @@ onMounted(async () => { /** * Fetch assets from the server */ + + const token = useCookies().get('token'); + if(token) { + gameStore.setToken(token); + gameStore.initConnection() + } + if (!(await assetStore.fetchAssets())) { notifications.addNotification({ message: 'Failed to fetch assets, the server may be offline or in maintenance. Please try again later.' }) }