store
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
export default defineNuxtRouteMiddleware((to, from) => {
|
||||
const accessToken = useCookie('access_token').value;
|
||||
try {
|
||||
const accessToken = useCookie('access_token').value;
|
||||
|
||||
const isPublicRoute =
|
||||
['/auth/login'].includes(to.path) ||
|
||||
to.path.startsWith('/auth/activation/');
|
||||
const isPublicRoute =
|
||||
['/auth/login'].includes(to.path) ||
|
||||
to.path.startsWith('/auth/activation/');
|
||||
|
||||
if (!accessToken && !isPublicRoute) {
|
||||
if (!accessToken && !isPublicRoute) {
|
||||
return navigateTo('/auth/login');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Auth middleware error:', error);
|
||||
return navigateTo('/auth/login');
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user