From fc0ced5550ca65185f5f78273e091e25b427ca81 Mon Sep 17 00:00:00 2001 From: Janderson Souza Matias Date: Wed, 26 Jun 2024 09:52:02 -0300 Subject: [PATCH] verify email --- src/modules/coach/service/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/coach/service/index.ts b/src/modules/coach/service/index.ts index 9236a79..7524ab9 100644 --- a/src/modules/coach/service/index.ts +++ b/src/modules/coach/service/index.ts @@ -10,11 +10,18 @@ export class CoachService { throw Error("Email is required"); } - if (await userRepository.exist({ where: { email: data.email } })) { + if ( + await userRepository.exist({ + where: { email: data.email.toLocaleLowerCase().trim() }, + }) + ) { throw Error("Exists a coach with this email"); } - return userRepository.save(data); + return userRepository.save({ + ...data, + email: data.email.toLocaleLowerCase().trim(), + }); }; static update = async (