From a18ca092097e2f2d1aa6705b4b1a2036e6d04f89 Mon Sep 17 00:00:00 2001 From: ledouxm Date: Wed, 12 Jun 2024 11:40:04 +0200 Subject: [PATCH] feat: add EMAIL_EMITTER and fix user creation --- packages/backend/src/envVars.ts | 1 + packages/backend/src/features/mail.ts | 4 ++-- packages/backend/src/services/userService.ts | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/envVars.ts b/packages/backend/src/envVars.ts index adffd987..9a499d99 100644 --- a/packages/backend/src/envVars.ts +++ b/packages/backend/src/envVars.ts @@ -26,6 +26,7 @@ const envSchema = z.object({ EMAIL_PORT: stringOrNumberAsNumber.default(465), EMAIL_USER: z.string(), EMAIL_PASSWORD: z.string(), + EMAIL_EMITTER: z.string(), }); export const ENV = envSchema.parse(process.env); diff --git a/packages/backend/src/features/mail.ts b/packages/backend/src/features/mail.ts index a1935209..a71e62ea 100644 --- a/packages/backend/src/features/mail.ts +++ b/packages/backend/src/features/mail.ts @@ -20,7 +20,7 @@ export const sendReportMail = ({ reportTitle?: string; }) => { return transporter.sendMail({ - from: "noreply@compte-rendu-vif.incubateur.net", + from: ENV.EMAIL_EMITTER, to: recipients, subject: "CR VIF - Compte rendu" + (reportTitle ? ` : ${reportTitle}` : ""), text: "Veuillez trouver ci-joint le compte rendu de votre rendez-vous.", @@ -35,7 +35,7 @@ export const sendReportMail = ({ export const sendPasswordResetMail = ({ email, temporaryLink }: { email: string; temporaryLink: string }) => { return transporter.sendMail({ - from: "noreply@compte-rendu-vif.incubateur.net", + from: ENV.EMAIL_EMITTER, to: email, subject: "CR VIF - Réinitialisation de mot de passe", text: `Voici le lien de réinitialisation de votre mot de passe : ${ENV.FRONTEND_URL}/reset-password/${temporaryLink}`, diff --git a/packages/backend/src/services/userService.ts b/packages/backend/src/services/userService.ts index 50d38c78..e3454678 100644 --- a/packages/backend/src/services/userService.ts +++ b/packages/backend/src/services/userService.ts @@ -53,7 +53,7 @@ export class UserService { const user = internalUser.user; - return { user: user, token: this.generateJWT(internalUser) }; + return { user: user, token: this.generateJWT(internalUser), refreshToken: this.generateRefreshToken(internalUser) }; } async getUserByEmail(email: string) {