Check if user is allowed to access

This commit is contained in:
2026-01-06 10:32:52 +01:00
parent 5856eea5f3
commit cb89a45743
+9 -4
View File
@@ -21,8 +21,9 @@ const deleteKey = (user: string) => delete jwtKeyCache[user];
* @returns `true` if the route is public, `false` otherwise.
*/
function isRoutePublic(route: string): boolean {
return PUBLIC_ROUTES.includes(route) ||
!!(route.match(/\..+$/)?.[0] ?? false);
return (
PUBLIC_ROUTES.includes(route) || !!(route.match(/\..+$/)?.[0] ?? false)
);
}
/**
@@ -67,10 +68,14 @@ export const handler: MiddlewareHandler<State>[] = [
);
if (context.state.isAuthenticated) {
const session: CasContent =
(getJwtPayload(cookies["sessionToken"]) as LoginJWT).user;
const session: CasContent = (
getJwtPayload(cookies["sessionToken"]) as LoginJWT
).user;
if (session.memberOf.includes("cn=amu:ufr:polytech:ldap")) {
console.log("Polytech trouvé !");
context.state.session = session;
}
}
return await context.next();
},