email not found error

This commit is contained in:
Vins 2023-12-20 15:07:59 +01:00
parent 4544b7209b
commit 2f4bd04ab3
2 changed files with 13 additions and 1 deletions

View File

@ -33,7 +33,15 @@ export default class UserController extends ApiController {
this.httpValidationError(response, "IdNot token undefined"); this.httpValidationError(response, "IdNot token undefined");
return; 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) { if(!user) {
this.httpUnauthorized(response); this.httpUnauthorized(response);

View File

@ -360,6 +360,10 @@ export default class IdNotService extends BaseService {
}, },
}; };
if(!userToAdd.contact.email) {
throw new Error("No email found");
}
let userHydrated = User.hydrate<User>(userToAdd); let userHydrated = User.hydrate<User>(userToAdd);
const user = await this.userService.create(userHydrated); const user = await this.userService.create(userHydrated);
const userOffice = await this.officeService.getByUid(user.office_uid); const userOffice = await this.officeService.getByUid(user.office_uid);