Skip to content

Commit

Permalink
feat: add EMAIL_EMITTER and fix user creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ledouxm authored Jun 12, 2024
2 parents 5b94c4e + a18ca09 commit f180586
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/backend/src/envVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/features/mail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -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}`,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/services/userService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f180586

Please sign in to comment.