Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions backend/src/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -58,28 +58,27 @@
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;

Expand Down Expand Up @@ -214,7 +213,7 @@

try {
// Vérifiez et décodez le token
const decoded: any = verify(token, jwtSecret);

Check warning on line 216 in backend/src/controllers/auth.controller.ts

View workflow job for this annotation

GitHub Actions / lint-api

Unexpected any. Specify a different type

Check warning on line 216 in backend/src/controllers/auth.controller.ts

View workflow job for this annotation

GitHub Actions / lint-api

Unexpected any. Specify a different type

// Trouvez l'utilisateur par ID
const user = await user_service.getUserById(decoded.userId);
Expand Down
Loading