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");
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);

View File

@ -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<User>(userToAdd);
const user = await this.userService.create(userHydrated);