Compare commits

..

3 Commits

Author SHA1 Message Date
djalim e64c3881fe feat: added logs
Build and push image / Check Deno code (push) Has been cancelled
Build and push image / Build Docker image (push) Has been cancelled
2026-05-05 12:52:20 +00:00
djalim a6042087dc test : changed test format + added playwright support 2026-05-05 12:52:20 +00:00
djalim 08894730a3 refactor(fresh.config): change server port to 80 and remove cert/key
Build and push image / Check Deno code (push) Successful in 6s
Build and push image / Build Docker image (push) Successful in 1m0s
Check Deno code / Check Deno code (pull_request) Has been cancelled
Tests / Unit tests (pull_request) Has been cancelled
Tests / Integration tests (pull_request) Has been cancelled
2026-05-01 20:30:02 +02:00
19 changed files with 58 additions and 62 deletions
-5
View File
@@ -63,11 +63,6 @@ export interface LoginJWT {
user: CasContent;
}
export function isEmployee(session: CasContent): boolean {
return session.eduPersonPrimaryAffiliation === "employee" ||
session.eduPersonPrimaryAffiliation === "faculty";
}
export type EmptyObject = Record<string | number | symbol, never>;
// deno-lint-ignore no-explicit-any
+3 -3
View File
@@ -1,7 +1,7 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { enseignements } from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
import { and, eq } from "npm:drizzle-orm@0.45.2";
const _NOT_FOUND = () =>
@@ -24,7 +24,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return new Response(JSON.stringify([]), {
headers: { "content-type": "application/json" },
});
@@ -40,7 +40,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
@@ -1,7 +1,7 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { enseignements } from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
import { and, eq } from "npm:drizzle-orm@0.45.2";
const NOT_FOUND = () =>
@@ -18,7 +18,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
@@ -50,7 +50,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
+2 -2
View File
@@ -1,7 +1,7 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { modules } from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
import { eq } from "npm:drizzle-orm@0.45.2";
export const handler: Handlers<null, AuthenticatedState> = {
@@ -21,7 +21,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return new Response(null, { status: 403 });
}
@@ -1,7 +1,7 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { ueModules } from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
import { and, eq } from "npm:drizzle-orm@0.45.2";
const NOT_FOUND = () =>
@@ -24,7 +24,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
@@ -58,7 +58,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
@@ -111,7 +111,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
+4 -3
View File
@@ -1,7 +1,7 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { mobilites } from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
import { eq } from "npm:drizzle-orm@0.45.2";
const VALID_STATUSES = [
@@ -46,14 +46,15 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
const employeeCheck = isEmployee(context.state.session);
const isEmployee =
context.state.session.eduPersonPrimaryAffiliation === "employee";
try {
const body = await request.json();
const { numEtud, duree, ecole, pays, status, idStage } = body;
// Students can only create mobilites for themselves
if (!employeeCheck && numEtud !== undefined) {
if (!isEmployee && numEtud !== undefined) {
// Students cannot set idStage or status
if (idStage || (status && status !== "contracts_received")) {
return new Response(null, { status: 403 });
@@ -1,7 +1,7 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { mobilites } from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
import { eq } from "npm:drizzle-orm@0.45.2";
const VALID_STATUSES = [
@@ -49,7 +49,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
@@ -115,7 +115,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
@@ -1,7 +1,7 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { mobilites } from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
import { eq } from "npm:drizzle-orm@0.45.2";
const CONTRACTS_DIR = "uploads/contracts";
@@ -118,7 +118,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return new Response(null, { status: 403 });
}
+2 -2
View File
@@ -1,7 +1,7 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { ajustements } from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
import { eq } from "npm:drizzle-orm@0.45.2";
export const handler: Handlers<null, AuthenticatedState> = {
@@ -47,7 +47,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return new Response(null, { status: 403 });
}
@@ -1,7 +1,7 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { ajustements } from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
import { and, eq } from "npm:drizzle-orm@0.45.2";
const NOT_FOUND = () =>
@@ -18,7 +18,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
@@ -47,7 +47,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
@@ -100,7 +100,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
+5 -5
View File
@@ -3,16 +3,16 @@ import {
makePartials,
} from "$root/defaults/makePartials.tsx";
import { FreshContext } from "$fresh/server.ts";
import { isEmployee, State } from "$root/defaults/interfaces.ts";
import { State } from "$root/defaults/interfaces.ts";
// deno-lint-ignore require-await
export async function Index(
_request: Request,
context: FreshContext<State>,
) {
const employeeCheck = isEmployee(
(context.state as unknown as { session: Record<string, string> }).session,
);
const isEmployee =
(context.state as unknown as { session: Record<string, string> }).session
.eduPersonPrimaryAffiliation === "employee";
return (
<div class="page-content">
@@ -25,7 +25,7 @@ export async function Index(
</strong>
.
</p>
{employeeCheck
{isEmployee
? (
<p>
Consultez les{" "}
+2 -2
View File
@@ -1,7 +1,7 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { stages } from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
import { eq } from "npm:drizzle-orm@0.45.2";
export const handler: Handlers<null, AuthenticatedState> = {
@@ -38,7 +38,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return new Response(null, { status: 403 });
}
+3 -3
View File
@@ -1,7 +1,7 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { mobilites, stages } from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
import { eq } from "npm:drizzle-orm@0.45.2";
const NOT_FOUND = () =>
@@ -41,7 +41,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
@@ -98,7 +98,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
+3 -3
View File
@@ -1,7 +1,7 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { promotions } from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
export const handler: Handlers<null, AuthenticatedState> = {
// #13 GET /promotions
@@ -9,7 +9,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return new Response(JSON.stringify([]), {
headers: { "content-type": "application/json" },
});
@@ -26,7 +26,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return new Response(null, { status: 403 });
}
@@ -10,7 +10,7 @@ import {
ueModules,
ues,
} from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
import { eq } from "npm:drizzle-orm@0.45.2";
const NOT_FOUND = () =>
@@ -27,7 +27,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
@@ -49,7 +49,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
@@ -76,7 +76,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
+3 -3
View File
@@ -1,7 +1,7 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { students } from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
import { eq } from "npm:drizzle-orm@0.45.2";
export const handler: Handlers<null, AuthenticatedState> = {
@@ -10,7 +10,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return new Response(JSON.stringify([]), {
headers: { "content-type": "application/json" },
});
@@ -33,7 +33,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return new Response(null, { status: 403 });
}
@@ -7,7 +7,7 @@ import {
stages,
students,
} from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
import { eq } from "npm:drizzle-orm@0.45.2";
const NOT_FOUND = () =>
@@ -24,7 +24,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
@@ -47,7 +47,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
@@ -86,7 +86,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
_request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return FORBIDDEN();
}
@@ -1,7 +1,7 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { students } from "$root/databases/schema.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { AuthenticatedState } from "$root/defaults/interfaces.ts";
// #9 POST /students/import-csv
export const handler: Handlers<null, AuthenticatedState> = {
@@ -9,7 +9,7 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
if (!isEmployee(context.state.session)) {
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
return new Response(null, { status: 403 });
}
+5 -5
View File
@@ -3,16 +3,16 @@ import {
makePartials,
} from "$root/defaults/makePartials.tsx";
import { FreshContext } from "$fresh/server.ts";
import { isEmployee, State } from "$root/defaults/interfaces.ts";
import { State } from "$root/defaults/interfaces.ts";
// deno-lint-ignore require-await
export async function Index(
_request: Request,
context: FreshContext<State>,
) {
const employeeStatus = isEmployee(
(context.state as unknown as { session: Record<string, string> }).session,
);
const isEmployee =
(context.state as unknown as { session: Record<string, string> }).session
.eduPersonPrimaryAffiliation === "employee";
return (
<div class="page-content">
@@ -25,7 +25,7 @@ export async function Index(
</strong>
.
</p>
{employeeStatus && (
{isEmployee && (
<p>
Consultez la{" "}
<a href="/students/consult" f-partial="/students/partials/consult">