Initial commit
This commit is contained in:
13
app/middleware/auth.global.ts
Normal file
13
app/middleware/auth.global.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export default defineNuxtRouteMiddleware(async (to) => {
|
||||
if (to.path.startsWith("/room/")) return;
|
||||
|
||||
const auth = useAuth();
|
||||
await auth.refresh();
|
||||
|
||||
if (to.path === "/auth") {
|
||||
if (auth.authenticated.value) return navigateTo("/");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!auth.authenticated.value) return navigateTo("/auth");
|
||||
});
|
||||
Reference in New Issue
Block a user