From 2f4bd04ab3669add179727e6bb18cc00e436afba Mon Sep 17 00:00:00 2001 From: Vins Date: Wed, 20 Dec 2023 15:07:59 +0100 Subject: [PATCH] email not found error --- src/app/api/idnot/UserController.ts | 10 +++++++++- src/services/common/IdNotService/IdNotService.ts | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app/api/idnot/UserController.ts b/src/app/api/idnot/UserController.ts index 77d79065..f614b419 100644 --- a/src/app/api/idnot/UserController.ts +++ b/src/app/api/idnot/UserController.ts @@ -33,7 +33,15 @@ export default class UserController extends ApiController { this.httpValidationError(response, "IdNot token undefined"); return; } - const user = await this.idNotService.getOrCreateUser(idNotToken); + + let user; + + try { + user = await this.idNotService.getOrCreateUser(idNotToken); + } catch (error: any) { + this.httpUnauthorized(error); + return; + } if(!user) { this.httpUnauthorized(response); diff --git a/src/services/common/IdNotService/IdNotService.ts b/src/services/common/IdNotService/IdNotService.ts index 5f9f9fda..edc58508 100644 --- a/src/services/common/IdNotService/IdNotService.ts +++ b/src/services/common/IdNotService/IdNotService.ts @@ -359,6 +359,10 @@ export default class IdNotService extends BaseService { updated_at: null, }, }; + + if(!userToAdd.contact.email) { + throw new Error("No email found"); + } let userHydrated = User.hydrate(userToAdd); const user = await this.userService.create(userHydrated);