Check if user is authenticated when a page is created
This commit is contained in:
parent
76f6c64708
commit
ad41d90a45
|
@ -69,9 +69,9 @@ const { width } = useWindowSize()
|
||||||
const showSetInstanceModal = ref(false)
|
const showSetInstanceModal = ref(false)
|
||||||
|
|
||||||
// Fetch user data on startup
|
// Fetch user data on startup
|
||||||
if (store.state.auth.authenticated) {
|
// NOTE: We're not checking if we're authenticated in the store,
|
||||||
store.dispatch('auth/fetchUser')
|
// because we want to learn if we are authenticated at all
|
||||||
}
|
store.dispatch('auth/fetchUser')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { User } from '~/types'
|
import type { BackendError, User } from '~/types'
|
||||||
import type { Module } from 'vuex'
|
import type { Module } from 'vuex'
|
||||||
import type { RootState } from '~/store/index'
|
import type { RootState } from '~/store/index'
|
||||||
import type { RouteLocationRaw } from 'vue-router'
|
import type { RouteLocationRaw } from 'vue-router'
|
||||||
|
@ -199,6 +199,11 @@ const store: Module<State, RootState> = {
|
||||||
dispatch('moderation/fetchContentFilters', null, { root: true })
|
dispatch('moderation/fetchContentFilters', null, { root: true })
|
||||||
])
|
])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if ((error as BackendError).response?.status === 401) {
|
||||||
|
logger.info('User is not authenticated')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
logger.error('Error while fetching user profile', error)
|
logger.error('Error while fetching user profile', error)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue