initial commit
This commit is contained in:
12
app/composables/useUser.js
Normal file
12
app/composables/useUser.js
Normal file
@@ -0,0 +1,12 @@
|
||||
export function useUser() {
|
||||
// eslint-disable-next-line no-undef
|
||||
const requestFetch = useRequestFetch()
|
||||
const { data: user, refresh } = useAsyncData(
|
||||
'user',
|
||||
() => (requestFetch ?? $fetch)('/api/me').catch(() => null),
|
||||
{ default: () => null },
|
||||
)
|
||||
const canEditPois = computed(() => user.value?.role === 'admin' || user.value?.role === 'leader')
|
||||
const isAdmin = computed(() => user.value?.role === 'admin')
|
||||
return { user, canEditPois, isAdmin, refresh }
|
||||
}
|
||||
Reference in New Issue
Block a user