Browse Source

use smtp user if no no-reply set

Milo Schwartz 6 months ago
parent
commit
60110350aa

+ 1 - 1
server/auth/resourceOtp.ts

@@ -26,7 +26,7 @@ export async function sendResourceOtpEmail(
         }),
         {
             to: email,
-            from: config.getRawConfig().email?.no_reply,
+            from: config.getNoReplyEmail(),
             subject: `Your one-time code to access ${resourceName}`
         }
     );

+ 1 - 1
server/auth/sendEmailVerificationCode.ts

@@ -21,7 +21,7 @@ export async function sendEmailVerificationCode(
         }),
         {
             to: email,
-            from: config.getRawConfig().email?.no_reply,
+            from: config.getNoReplyEmail(),
             subject: "Verify your email address"
         }
     );

+ 8 - 2
server/lib/config.ts

@@ -41,7 +41,7 @@ const configSchema = z.object({
             .transform((url) => url.toLowerCase()),
         log_level: z.enum(["debug", "info", "warn", "error"]),
         save_logs: z.boolean(),
-        log_failed_attempts: z.boolean().optional(),
+        log_failed_attempts: z.boolean().optional()
     }),
     server: z.object({
         external_port: portSchema
@@ -128,7 +128,7 @@ const configSchema = z.object({
             smtp_user: z.string().optional(),
             smtp_pass: z.string().optional(),
             smtp_secure: z.boolean().optional(),
-            no_reply: z.string().email()
+            no_reply: z.string().email().optional()
         })
         .optional(),
     users: z.object({
@@ -280,6 +280,12 @@ export class Config {
         return this.rawConfig.app.base_domain;
     }
 
+    public getNoReplyEmail(): string | undefined {
+        return (
+            this.rawConfig.email?.no_reply || this.rawConfig.email?.smtp_user
+        );
+    }
+
     private createTraefikConfig() {
         try {
             // check if traefik_config.yml and dynamic_config.yml exists in APP_PATH/traefik

+ 1 - 1
server/routers/auth/requestPasswordReset.ts

@@ -95,7 +95,7 @@ export async function requestPasswordReset(
                 link: url
             }),
             {
-                from: config.getRawConfig().email?.no_reply,
+                from: config.getNoReplyEmail(),
                 to: email,
                 subject: "Reset your password"
             }

+ 1 - 1
server/routers/auth/resetPassword.ts

@@ -163,7 +163,7 @@ export async function resetPassword(
         });
 
         await sendEmail(ConfirmPasswordReset({ email }), {
-            from: config.getRawConfig().email?.no_reply,
+            from: config.getNoReplyEmail(),
             to: email,
             subject: "Password Reset Confirmation"
         });

+ 1 - 1
server/routers/user/inviteUser.ts

@@ -168,7 +168,7 @@ export async function inviteUser(
                 }),
                 {
                     to: email,
-                    from: config.getRawConfig().email?.no_reply,
+                    from: config.getNoReplyEmail(),
                     subject: "You're invited to join a Fossorial organization"
                 }
             );