forked from Wroclaw/WorkshopTasker
Initial commit
This commit is contained in:
commit
1e63e008af
48 changed files with 12715 additions and 0 deletions
10
middleware/auth.ts
Normal file
10
middleware/auth.ts
Normal 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 } });
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue