Skip to content

Commit aaf0268

Browse files
committed
Revert "fix: block CAS account creation (temporary)"
This reverts commit e996220.
1 parent a6bb834 commit aaf0268

1 file changed

Lines changed: 23 additions & 24 deletions

File tree

‎backend/src/controllers/auth.controller.ts‎

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import bcrypt from 'bcryptjs';
2-
//import bigInt from 'big-integer';
2+
import bigInt from 'big-integer';
33
import { sign, verify } from 'jsonwebtoken';
44
import type { EmailOptions } from '../types/email';
55
import { templateResetPassword } from '../email/email.registry';
66
import { compileTemplate } from '../email/email.renderer';
77
import * as auth_service from '../services/auth.service';
8-
//import * as banned_service from '../services/banned.service';
8+
import * as banned_service from '../services/banned.service';
99
import * as email_service from '../services/email.service';
1010
import * as registration_service from '../services/registration.service';
1111
import * as role_service from '../services/role.service';
@@ -58,28 +58,27 @@ export const handlecasticket: AppRequestHandler<unknown, CasTicketQuery> = async
5858
const CASuser = await auth_service.validateCASTicket(ticket);
5959

6060
if (CASuser && CASuser.email && CASuser.givenName && CASuser.sn) {
61-
// TEMPORAIRE POUR BLOQUER LA CREATION DE COMPTES NOUVEAUX
62-
// remettre user en let
63-
const user = await user_service.getUserByEmail(CASuser.email.toLowerCase());
64-
// if (!user) {
65-
// const isBanned = await banned_service.getBannedByEmail(CASuser.email);
66-
//
67-
// if (isBanned) {
68-
// Unauthorized(res, { msg: 'Unauthorized: user email prohibited' });
69-
// }
70-
//
71-
// const password = bigInt.randBetween(bigInt(2).pow(255), bigInt(2).pow(256).minus(1)).toString();
72-
// await user_service.createUser(
73-
// CASuser.givenName,
74-
// CASuser.sn,
75-
// CASuser.email,
76-
// true,
77-
// 'Student',
78-
// ' ',
79-
// password,
80-
// );
81-
// user = await user_service.getUserByEmail(CASuser.email.toLowerCase());
82-
// }
61+
// Assurez-vous que user.email est un string
62+
let user = await user_service.getUserByEmail(CASuser.email.toLowerCase());
63+
if (!user) {
64+
const isBanned = await banned_service.getBannedByEmail(CASuser.email);
65+
66+
if (isBanned) {
67+
Unauthorized(res, { msg: 'Unauthorized: user email prohibited' });
68+
}
69+
70+
const password = bigInt.randBetween(bigInt(2).pow(255), bigInt(2).pow(256).minus(1)).toString();
71+
await user_service.createUser(
72+
CASuser.givenName,
73+
CASuser.sn,
74+
CASuser.email,
75+
true,
76+
'Student',
77+
' ',
78+
password,
79+
);
80+
user = await user_service.getUserByEmail(CASuser.email.toLowerCase());
81+
}
8382

8483
const id = user?.id;
8584

0 commit comments

Comments
 (0)