auth middlewares
This commit is contained in:
13
frontend/middleware/authenticated.ts
Normal file
13
frontend/middleware/authenticated.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export default defineNuxtRouteMiddleware((to, _from) => {
|
||||
if (
|
||||
useAuthSession().value != null ||
|
||||
to.name === 'signin' ||
|
||||
to.name === 'signup'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
return navigateTo({
|
||||
path: '/signin',
|
||||
});
|
||||
});
|
||||
9
frontend/middleware/not-authenticated.ts
Normal file
9
frontend/middleware/not-authenticated.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export default defineNuxtRouteMiddleware((to, _from) => {
|
||||
if (useAuthSession().value == null && to.name !== 'index') {
|
||||
return;
|
||||
}
|
||||
|
||||
return navigateTo({
|
||||
path: '/',
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user