Merge branch 'dev' into staging

This commit is contained in:
Vins 2024-02-28 12:06:34 +01:00
commit 932329e950

View File

@ -25,6 +25,7 @@ export default class UserController extends ApiController {
protected async getUserInfosFromIdnot(req: Request, response: Response) { protected async getUserInfosFromIdnot(req: Request, response: Response) {
try { try {
const code = req.params["code"]; const code = req.params["code"];
if (!code) throw new Error("code is required"); if (!code) throw new Error("code is required");
const idNotToken = await this.idNotService.getIdNotToken(code); const idNotToken = await this.idNotService.getIdNotToken(code);
@ -41,9 +42,12 @@ export default class UserController extends ApiController {
return; return;
} }
await this.idNotService.updateUser(user.uid);
//Whitelist feature //Whitelist feature
//Get user with contact //Get user with contact
const prismaUser = await this.userService.getByUid(user.uid, {contact: true }); const prismaUser = await this.userService.getByUid(user.uid, {contact: true });
if (!prismaUser) { if (!prismaUser) {
this.httpNotFoundRequest(response, "user not found"); this.httpNotFoundRequest(response, "user not found");
return; return;
@ -58,15 +62,16 @@ export default class UserController extends ApiController {
} }
//Check if user is whitelisted //Check if user is whitelisted
const isWhitelisted = await this.whitelistService.getByEmail(userHydrated.contact!.email); const isWhitelisted = await this.whitelistService.getByEmail(userHydrated.contact!.email);
//If not whitelisted, return 409 Not whitelisted //If not whitelisted, return 409 Not whitelisted
if (!isWhitelisted) { if (!isWhitelisted || isWhitelisted.length === 0) {
this.httpNotWhitelisted(response); this.httpNotWhitelisted(response);
return; return;
} }
await this.idNotService.updateUser(user.uid);
await this.idNotService.updateOffice(user.office_uid); await this.idNotService.updateOffice(user.office_uid);
const payload = await this.authService.getUserJwtPayload(user.idNot); const payload = await this.authService.getUserJwtPayload(user.idNot);