use smtp user if no no-reply set

This commit is contained in:
Milo Schwartz 2025-01-28 21:26:34 -05:00
parent a57f0ab360
commit 60110350aa
No known key found for this signature in database
6 changed files with 13 additions and 7 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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