mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-16 21:58:40 +00:00
16 lines
327 B
TypeScript
16 lines
327 B
TypeScript
|
import { useAuthStore } from "~~/stores/auth";
|
||
|
|
||
|
export default defineNuxtRouteMiddleware(async () => {
|
||
|
const auth = useAuthStore();
|
||
|
const api = useUserApi();
|
||
|
|
||
|
if (!auth.self) {
|
||
|
const { data, error } = await api.user.self();
|
||
|
if (error) {
|
||
|
navigateTo("/");
|
||
|
}
|
||
|
|
||
|
auth.$patch({ self: data.item });
|
||
|
}
|
||
|
});
|