From 6b85ee3eb66200b872e09ba744ce529e84cda3a9 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 29 Jul 2014 13:47:54 -0400 Subject: [PATCH] Make sure all user emails that can be sent in enterprise properly adjust to the app's URL --- app.py | 3 +++ util/useremails.py | 30 ++++++++++++++++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/app.py b/app.py index ac6f93a96..5d59ebef6 100644 --- a/app.py +++ b/app.py @@ -83,3 +83,6 @@ notification_queue = WorkQueue(app.config['NOTIFICATION_QUEUE_NAME'], tf) database.configure(app.config) model.config.app_config = app.config model.config.store = storage + +def get_app_url(): + return '%s://%s' % (app.config['PREFERRED_URL_SCHEME'], app.config['SERVER_HOSTNAME']) diff --git a/util/useremails.py b/util/useremails.py index 4dd6a37ea..0a78da7e3 100644 --- a/util/useremails.py +++ b/util/useremails.py @@ -1,33 +1,33 @@ from flask.ext.mail import Message -from app import mail, app +from app import mail, app, get_app_url CONFIRM_MESSAGE = """ This email address was recently used to register the username '%s' -at Quay.io.
+at Quay.io.

To confirm this email address, please click the following link:
-https://quay.io/confirm?code=%s +%s/confirm?code=%s """ CHANGE_MESSAGE = """ This email address was recently asked to become the new e-mail address for username '%s' -at Quay.io.
+at Quay.io.

To confirm this email address, please click the following link:
-https://quay.io/confirm?code=%s +%s/confirm?code=%s """ RECOVERY_MESSAGE = """ -A user at Quay.io has attempted to recover their account -using this email.
+A user at Quay.io has attempted to recover their account +using this email address.

If you made this request, please click the following link to recover your account and change your password: -https://quay.io/recovery?code=%s
+%s/recovery?code=%s

If you did not make this request, your account has not been compromised and the user was not given access. Please disregard this email.
@@ -58,10 +58,11 @@ Thanks and have a great day!
AUTH_FORREPO_MESSAGE = """ -A request has been made to send notifications to this email address for the Quay.io repository %s/%s. +A request has been made to send notifications to this email address for the +Quay.io repository %s/%s.
To confirm this email address, please click the following link:
-https://quay.io/authrepoemail?code=%s +%s/authrepoemail?code=%s """ @@ -72,7 +73,7 @@ def send_change_email(username, email, token): msg = Message('Quay.io email change. Please confirm your email.', sender='support@quay.io', # Why do I need this? recipients=[email]) - msg.html = CHANGE_MESSAGE % (username, token, token) + msg.html = CHANGE_MESSAGE % (username, get_app_url(), get_app_url(), token, get_app_url(), token) mail.send(msg) @@ -80,7 +81,7 @@ def send_confirmation_email(username, email, token): msg = Message('Welcome to Quay.io! Please confirm your email.', sender='support@quay.io', # Why do I need this? recipients=[email]) - msg.html = CONFIRM_MESSAGE % (username, token, token) + msg.html = CONFIRM_MESSAGE % (username, get_app_url(), get_app_url(), token, get_app_url(), token) mail.send(msg) @@ -88,7 +89,8 @@ def send_repo_authorization_email(namespace, repository, email, token): msg = Message('Quay.io Notification: Please confirm your email.', sender='support@quay.io', # Why do I need this? recipients=[email]) - msg.html = AUTH_FORREPO_MESSAGE % (namespace, repository, namespace, repository, token, token) + msg.html = AUTH_FORREPO_MESSAGE % (get_app_url(), get_app_url(), namespace, repository, namespace, + repository, get_app_url(), token, get_app_url(), token) mail.send(msg) @@ -96,7 +98,7 @@ def send_recovery_email(email, token): msg = Message('Quay.io account recovery.', sender='support@quay.io', # Why do I need this? recipients=[email]) - msg.html = RECOVERY_MESSAGE % (token, token) + msg.html = RECOVERY_MESSAGE % (get_app_url(), get_app_url(), token, get_app_url(), token) mail.send(msg)