2023-12-19 12:46:55 +00:00
|
|
|
import {useWorkspacesStore} from "~/stores/workspaces.js";
|
|
|
|
|
2023-12-16 18:21:03 +00:00
|
|
|
export default defineNuxtRouteMiddleware(async(to, from) => {
|
|
|
|
const authStore = useAuthStore()
|
|
|
|
authStore.initStore(useCookie('token').value, useCookie('admin_token').value)
|
|
|
|
|
|
|
|
if (authStore.token && !authStore.user) {
|
|
|
|
const {data, error} = await useOpnApi('user')
|
|
|
|
authStore.setUser(data.value)
|
|
|
|
}
|
|
|
|
})
|