feat(email): add provider abstraction and HTML templates
Add pluggable email provider system supporting SMTP, Mailgun, and SendGrid with factory pattern for runtime provider selection. Includes branded HTML email templates for verification, password reset, MFA notifications, and organization invites. Also rebrands all email content from Gatehouse to Secuird, adds email provider configuration options, and fixes duplicate log handlers in development mode.
This commit is contained in:
@@ -32,12 +32,12 @@ def register():
|
||||
verify_token = EmailVerificationToken.generate(user_id=user.id)
|
||||
app_url = current_app.config.get("APP_URL", "http://localhost:8080")
|
||||
verify_link = f"{app_url}/verify-email?token={verify_token.token}"
|
||||
subject = "Verify your Gatehouse email address"
|
||||
subject = "Verify your Secuird email address"
|
||||
body = (
|
||||
f"Hi {user.full_name or user.email},\n\n"
|
||||
f"Welcome to Gatehouse! Please verify your email address by clicking the link below (valid for 24 hours):\n"
|
||||
f"Welcome to Secuird! Please verify your email address by clicking the link below (valid for 24 hours):\n"
|
||||
f"{verify_link}\n\n"
|
||||
f"Gatehouse Security Team"
|
||||
f"Secuird Security Team"
|
||||
)
|
||||
NotificationService._send_email_async(to_address=user.email, subject=subject, body=body)
|
||||
except Exception as exc:
|
||||
|
||||
@@ -29,14 +29,14 @@ def forgot_password():
|
||||
reset_link = f"{app_url}/reset-password?token={reset_token.token}"
|
||||
NotificationService._send_email_async(
|
||||
to_address=user.email,
|
||||
subject="Reset your Gatehouse password",
|
||||
subject="Reset your Secuird password",
|
||||
body=(
|
||||
f"Hi {user.full_name or user.email},\n\n"
|
||||
f"You requested a password reset for your Gatehouse account.\n\n"
|
||||
f"You requested a password reset for your Secuird account.\n\n"
|
||||
f"Click the link below to reset your password (valid for 2 hours):\n"
|
||||
f"{reset_link}\n\n"
|
||||
f"If you did not request this, you can safely ignore this email.\n\n"
|
||||
f"Gatehouse Security Team"
|
||||
f"Secuird Security Team"
|
||||
),
|
||||
)
|
||||
_logger.info(f"Password reset token generated for user {user.id}")
|
||||
@@ -131,12 +131,12 @@ def resend_verification():
|
||||
verify_link = f"{app_url}/verify-email?token={verify_token.token}"
|
||||
NotificationService._send_email_async(
|
||||
to_address=user.email,
|
||||
subject="Verify your Gatehouse email address",
|
||||
subject="Verify your Secuird email address",
|
||||
body=(
|
||||
f"Hi {user.full_name or user.email},\n\n"
|
||||
f"Please verify your email address by clicking the link below (valid for 24 hours):\n"
|
||||
f"{verify_link}\n\n"
|
||||
f"Gatehouse Security Team"
|
||||
f"Secuird Security Team"
|
||||
),
|
||||
)
|
||||
_logger.info(f"Verification email sent for user {user.id}")
|
||||
@@ -202,13 +202,13 @@ def resend_activation():
|
||||
activate_link = f"{app_url}/activate?code={code}"
|
||||
NotificationService._send_email_async(
|
||||
to_address=user.email,
|
||||
subject="Activate your Gatehouse account",
|
||||
subject="Activate your Secuird account",
|
||||
body=(
|
||||
f"Hi {user.full_name or user.email},\n\n"
|
||||
f"Please activate your Gatehouse account by clicking the link below:\n"
|
||||
f"Please activate your Secuird account by clicking the link below:\n"
|
||||
f"{activate_link}\n\n"
|
||||
f"If you did not create an account, you can safely ignore this email.\n\n"
|
||||
f"Gatehouse Security Team"
|
||||
f"Secuird Security Team"
|
||||
),
|
||||
)
|
||||
_logger.info(f"Activation email re-sent to {user.id}")
|
||||
|
||||
@@ -39,12 +39,12 @@ def create_org_invite(org_id):
|
||||
|
||||
NotificationService._send_email_async(
|
||||
to_address=email,
|
||||
subject=f"You're invited to join {org.name} on Gatehouse",
|
||||
subject=f"You're invited to join {org.name} on Secuird",
|
||||
body=(
|
||||
f"You've been invited to join {org.name} on Gatehouse.\n\n"
|
||||
f"You've been invited to join {org.name} on Secuird.\n\n"
|
||||
f"Click the link below to accept the invitation (valid for 7 days):\n"
|
||||
f"{invite_link}\n\n"
|
||||
f"Gatehouse Security Team"
|
||||
f"Secuird Security Team"
|
||||
),
|
||||
)
|
||||
logging.getLogger(__name__).info(f"[INVITE] Email queued for {email}")
|
||||
|
||||
@@ -167,9 +167,9 @@ def send_mfa_reminder(org_id, user_id):
|
||||
body=(
|
||||
f"Hi {user.full_name or user.email},\n\n"
|
||||
"Your organization administrator has asked you to set up "
|
||||
"multi-factor authentication (MFA) on your Gatehouse account.\n\n"
|
||||
"multi-factor authentication (MFA) on your Secuird account.\n\n"
|
||||
"Please log in and configure MFA as soon as possible.\n\n"
|
||||
"Gatehouse Security Team"
|
||||
"Secuird Security Team"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user