mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2026-04-03 01:11:48 +02:00
refactor: remove pocketbase (#1138)
This commit is contained in:
@@ -1,5 +1,46 @@
|
||||
<script setup lang="ts">
|
||||
import Toaster from '@/components/ui/toast/Toaster.vue'
|
||||
|
||||
import { onMounted, watch } from 'vue'
|
||||
import { RouterView } from 'vue-router'
|
||||
|
||||
import { useAuthStore } from '@/store/auth'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
|
||||
const fetchUser = () => {
|
||||
if (!authStore.token) {
|
||||
authStore.setUser(undefined)
|
||||
authStore.setPermissions([])
|
||||
return
|
||||
}
|
||||
|
||||
fetch('/auth/user', { headers: { Authorization: `Bearer ${authStore.token}` } }).then(
|
||||
(response) => {
|
||||
if (response.ok) {
|
||||
response.json().then((user) => {
|
||||
if (user) {
|
||||
authStore.setUser(user.user)
|
||||
authStore.setPermissions(user.permissions)
|
||||
} else {
|
||||
authStore.setUser(undefined)
|
||||
authStore.setPermissions([])
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchUser()
|
||||
})
|
||||
|
||||
watch(
|
||||
() => authStore.token,
|
||||
() => fetchUser(),
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user