feat: minor format + upgrade
Some checks failed
Lint front projects / Next front lint (push) Has been cancelled
Test front projects / Next front test (push) Has been cancelled

This commit is contained in:
2026-02-01 12:19:00 +01:00
parent 695342e19a
commit 467f5a9193
3 changed files with 5654 additions and 4086 deletions

View File

@@ -4,43 +4,43 @@ import type { User } from "~/stores/user";
const LOGIN_ROUTE = "/login";
export default defineNuxtRouteMiddleware((to, from) => {
let session: string | null = null;
let session: string | null = null;
// Not secured route// Recover user session
if (
to.path.startsWith("/favicon.ico") ||
to.path.startsWith("/assets/") ||
to.path.startsWith(LOGIN_ROUTE)
) {
return;
}
// Not secured route// Recover user session
if (
to.path.startsWith("/favicon.ico") ||
to.path.startsWith("/assets/") ||
to.path.startsWith(LOGIN_ROUTE)
) {
return;
}
// Recover user session
// NOTE: using the sessionStorage will not allow the user to have multiple tabs, to communicate them one can use the
// broadcast channel, although its not the safest way: https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API
try {
session = sessionStorage.getItem(
USER_SESSION_STORAGE_KEY,
);
// Recover user session
// NOTE: using the sessionStorage will not allow the user to have multiple tabs, to communicate them one can use the
// broadcast channel, although its not the safest way: https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API
try {
session = sessionStorage.getItem(
USER_SESSION_STORAGE_KEY,
);
// Manage secured routes
if (session) {
const user = JSON.parse(session) as User;
if (
user.apiSession?.exp &&
user.apiSession.exp > Date.now()
) {
// try refresh token if it exists
// else just redirect to login
return navigateTo(LOGIN_ROUTE);
}
return;
} else {
return navigateTo(LOGIN_ROUTE);
}
} catch (e) {
console.error(">> [!] Not in client", e);
}
// Manage secured routes
if (session) {
const user = JSON.parse(session) as User;
if (
user.apiSession?.exp &&
user.apiSession.exp > Date.now()
) {
// try refresh token if it exists
// else just redirect to login
return navigateTo(LOGIN_ROUTE);
}
return;
} else {
return navigateTo(LOGIN_ROUTE);
}
} catch (e) {
console.error(">> [!] Not in client", e);
}
console.log(">> Global Middleware from ", from.path);
console.log(">> Global Middleware from ", from.path);
});

View File

File diff suppressed because it is too large Load Diff

4736
front/package-lock.json generated
View File

File diff suppressed because it is too large Load Diff