Initial commit

This commit is contained in:
Wroclaw 2023-05-11 06:03:22 +02:00
commit 1e63e008af
48 changed files with 12715 additions and 0 deletions

10
middleware/auth.ts Normal file
View file

@ -0,0 +1,10 @@
import { defineNuxtRouteMiddleware, navigateTo, useFetch } from "nuxt/app";
export default defineNuxtRouteMiddleware(async (to, from) => {
// FIXME: Check authorisation in another way (401 unauthorised) instead querying api directly
const me = await useFetch("/api/users/me", {});
if (!me.error.value) return;
if (process.client) console.log(me.error.value);
return navigateTo({ path: "/login", query: { redirect: to.fullPath } });
});