diff --git a/auth/email.py b/auth/email.py index e5a0b32b..bbccd6e6 100644 --- a/auth/email.py +++ b/auth/email.py @@ -12,18 +12,27 @@ MAILGUN_FROM = "postmaster " % (MAILGUN_DOMAIN) AUTH_URL = "%s/email_authorize" % (BACKEND_URL) +email_templates = {"confirm_email" : "", "auth_email" : "", "reset_password_email" : ""} + +def load_email_templates(): + for name in email_templates: + filename = "templates/%s.tmpl" % name + with open(filename) as f: + email_templates[name] = f.read() + print("all email templates loaded") + async def send_confirm_email(user): - text = "To confirm registration follow the link" + text = email_templates["confirm_email"] token = await EmailAuthenticate.get_email_token(user) await send_email(user, AUTH_URL, text, token) async def send_auth_email(user): - text = "To enter the site follow the link" + text = email_templates["auth_email"] token = await EmailAuthenticate.get_email_token(user) await send_email(user, AUTH_URL, text, token) async def send_reset_password_email(user): - text = "To reset password follow the link" + text = email_templates["reset_password_email"] token = await ResetPassword.get_reset_token(user) await send_email(user, RESET_PWD_URL, text, token) diff --git a/templates/auth_email.tmpl b/templates/auth_email.tmpl new file mode 100644 index 00000000..9135da9a --- /dev/null +++ b/templates/auth_email.tmpl @@ -0,0 +1 @@ +To enter the site follow the link diff --git a/templates/confirm_email.tmpl b/templates/confirm_email.tmpl new file mode 100644 index 00000000..9d56c41d --- /dev/null +++ b/templates/confirm_email.tmpl @@ -0,0 +1 @@ +To confirm registration follow the link diff --git a/templates/reset_password_email.tmpl b/templates/reset_password_email.tmpl new file mode 100644 index 00000000..51a68604 --- /dev/null +++ b/templates/reset_password_email.tmpl @@ -0,0 +1 @@ +To reset password follow the link