diff --git a/api-service/api/src/controllers/codes.ts b/api-service/api/src/controllers/codes.ts index cdfb8329..f1a2a597 100644 --- a/api-service/api/src/controllers/codes.ts +++ b/api-service/api/src/controllers/codes.ts @@ -124,11 +124,6 @@ export async function generateCodeFor(req: Request, res: Response, next: NextFun // Divide the code in two parts const firstPart = code.substring(0, code.length/2); const secondPart = code.substring(code.length/2, code.length); - - res.locals.code = StatusCodes.CREATED; - res.locals.data = firstPart; - - const message = { from: 'ChainVote', to: res.locals.user.email, @@ -138,12 +133,9 @@ export async function generateCodeFor(req: Request, res: Response, next: NextFun This is the other part of your code: ${secondPart} ` }; - const info = await mailer.sendMail(message); + await mailer.sendMail(message).catch((error: any) => next(error)); res.locals.code = StatusCodes.CREATED; - res.locals.data = { - msg: "Email sent", - info: info.messageId - } + res.locals.data = firstPart; } catch (error) { return next(transformHyperledgerError(error)); } diff --git a/api-service/api/src/controllers/users.ts b/api-service/api/src/controllers/users.ts index 07662287..13e914a9 100644 --- a/api-service/api/src/controllers/users.ts +++ b/api-service/api/src/controllers/users.ts @@ -185,8 +185,6 @@ export async function passwordForgotten(req: Request, res: Response, next: NextF const data = {'password': password} try { await User.updateOne({ email: req.body.email }, data); - res.locals.code = StatusCodes.OK; - res.locals.data = true; } catch(error) { return next(error); } @@ -199,11 +197,10 @@ export async function passwordForgotten(req: Request, res: Response, next: NextF This is the new password: ${password} ` }; - const info = await mailer.sendMail(message) - res.locals.code = 201 + await mailer.sendMail(message).catch((error: any) => next(error)); + res.locals.code = StatusCodes.CREATED; res.locals.data = { - msg: "Email sent", - info: info.messageId + msg: "Email sent" } return next(); } diff --git a/frontend/src/components/ElectionCardComponent.vue b/frontend/src/components/ElectionCardComponent.vue index bf9794b5..0ad751fe 100644 --- a/frontend/src/components/ElectionCardComponent.vue +++ b/frontend/src/components/ElectionCardComponent.vue @@ -13,7 +13,7 @@
diff --git a/frontend/src/components/ElectionComponent.vue b/frontend/src/components/ElectionComponent.vue index 3dc997c3..a72dd077 100644 --- a/frontend/src/components/ElectionComponent.vue +++ b/frontend/src/components/ElectionComponent.vue @@ -6,7 +6,7 @@ diff --git a/frontend/src/components/vote/RequestCodeModal.vue b/frontend/src/components/vote/RequestCodeModal.vue index 8c22349f..970f24ee 100644 --- a/frontend/src/components/vote/RequestCodeModal.vue +++ b/frontend/src/components/vote/RequestCodeModal.vue @@ -19,6 +19,7 @@ function sendCodeRequest(id: string) { axios.post(`${apiEndpoints.API_SERVER}/code/generate`, { electionId: id }) .then((response) => { code.value = response.data.data + console.log(code.value) codeRequest.value = true requestError.value = false }).catch((error) => { @@ -51,7 +52,7 @@ function sendCodeRequest(id: string) {