1
0
forked from noxious/client

Get token from cookies to prevent logging in on refresh.

This commit is contained in:
Zaxiure 2024-09-07 23:34:37 +02:00
parent c7d2937523
commit c4e7eb81ef
No known key found for this signature in database

View File

@ -33,6 +33,7 @@ import { login, register } from '@/services/authentication'
import { useNotificationStore } from '@/stores/notifications' import { useNotificationStore } from '@/stores/notifications'
import { useGameStore } from '@/stores/game' import { useGameStore } from '@/stores/game'
import { useAssetStore } from '@/stores/assets' import { useAssetStore } from '@/stores/assets'
import { useCookies } from '@vueuse/integrations/useCookies'
const gameStore = useGameStore() const gameStore = useGameStore()
const notifications = useNotificationStore() const notifications = useNotificationStore()
@ -45,6 +46,13 @@ onMounted(async () => {
/** /**
* Fetch assets from the server * Fetch assets from the server
*/ */
const token = useCookies().get('token');
if(token) {
gameStore.setToken(token);
gameStore.initConnection()
}
if (!(await assetStore.fetchAssets())) { if (!(await assetStore.fetchAssets())) {
notifications.addNotification({ message: 'Failed to fetch assets, the server may be offline or in maintenance. Please try again later.' }) notifications.addNotification({ message: 'Failed to fetch assets, the server may be offline or in maintenance. Please try again later.' })
} }