From aaf02683f679b52502a44f467ab446a506271b70 Mon Sep 17 00:00:00 2001 From: Antoine Date: Tue, 1 Sep 2026 18:27:30 +0200 Subject: [PATCH] Revert "fix: block CAS account creation (temporary)" This reverts commit e9962204c60c44ebbfb917684feb71f8b8166c65. --- backend/src/controllers/auth.controller.ts | 47 +++++++++++----------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/backend/src/controllers/auth.controller.ts b/backend/src/controllers/auth.controller.ts index e8754c6..924f21d 100644 --- a/backend/src/controllers/auth.controller.ts +++ b/backend/src/controllers/auth.controller.ts @@ -1,11 +1,11 @@ import bcrypt from 'bcryptjs'; -//import bigInt from 'big-integer'; +import bigInt from 'big-integer'; import { sign, verify } from 'jsonwebtoken'; import type { EmailOptions } from '../types/email'; import { templateResetPassword } from '../email/email.registry'; import { compileTemplate } from '../email/email.renderer'; import * as auth_service from '../services/auth.service'; -//import * as banned_service from '../services/banned.service'; +import * as banned_service from '../services/banned.service'; import * as email_service from '../services/email.service'; import * as registration_service from '../services/registration.service'; import * as role_service from '../services/role.service'; @@ -58,28 +58,27 @@ export const handlecasticket: AppRequestHandler = async const CASuser = await auth_service.validateCASTicket(ticket); if (CASuser && CASuser.email && CASuser.givenName && CASuser.sn) { - // TEMPORAIRE POUR BLOQUER LA CREATION DE COMPTES NOUVEAUX - // remettre user en let - const user = await user_service.getUserByEmail(CASuser.email.toLowerCase()); - // if (!user) { - // const isBanned = await banned_service.getBannedByEmail(CASuser.email); - // - // if (isBanned) { - // Unauthorized(res, { msg: 'Unauthorized: user email prohibited' }); - // } - // - // const password = bigInt.randBetween(bigInt(2).pow(255), bigInt(2).pow(256).minus(1)).toString(); - // await user_service.createUser( - // CASuser.givenName, - // CASuser.sn, - // CASuser.email, - // true, - // 'Student', - // ' ', - // password, - // ); - // user = await user_service.getUserByEmail(CASuser.email.toLowerCase()); - // } + // Assurez-vous que user.email est un string + let user = await user_service.getUserByEmail(CASuser.email.toLowerCase()); + if (!user) { + const isBanned = await banned_service.getBannedByEmail(CASuser.email); + + if (isBanned) { + Unauthorized(res, { msg: 'Unauthorized: user email prohibited' }); + } + + const password = bigInt.randBetween(bigInt(2).pow(255), bigInt(2).pow(256).minus(1)).toString(); + await user_service.createUser( + CASuser.givenName, + CASuser.sn, + CASuser.email, + true, + 'Student', + ' ', + password, + ); + user = await user_service.getUserByEmail(CASuser.email.toLowerCase()); + } const id = user?.id;