fix: faculty users are now recognized as employees
Check Deno code / Check Deno code (push) Has been cancelled
Tests / Unit tests (push) Has been cancelled
Tests / Integration tests (push) Has been cancelled

This commit is contained in:
2026-05-05 15:29:02 +02:00
parent 0f87bc18c3
commit 49bcc3083a
19 changed files with 62 additions and 58 deletions
+3 -4
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 } from "$root/defaults/interfaces.ts";
import { AuthenticatedState, isEmployee } from "$root/defaults/interfaces.ts";
import { eq } from "npm:drizzle-orm@0.45.2";
const VALID_STATUSES = [
@@ -46,15 +46,14 @@ export const handler: Handlers<null, AuthenticatedState> = {
request: Request,
context: FreshContext<AuthenticatedState>,
): Promise<Response> {
const isEmployee =
context.state.session.eduPersonPrimaryAffiliation === "employee";
const employeeCheck = isEmployee(context.state.session);
try {
const body = await request.json();
const { numEtud, duree, ecole, pays, status, idStage } = body;
// Students can only create mobilites for themselves
if (!isEmployee && numEtud !== undefined) {
if (!employeeCheck && numEtud !== undefined) {
// Students cannot set idStage or status
if (idStage || (status && status !== "contracts_received")) {
return new Response(null, { status: 403 });