Get token from cookies to prevent logging in on refresh.
This commit is contained in:
parent
c7d2937523
commit
c4e7eb81ef
@ -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.' })
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user