Make sure all user emails that can be sent in enterprise properly adjust to the app's URL

This commit is contained in:
Joseph Schorr 2014-07-29 13:47:54 -04:00
parent a2f0f57414
commit 6b85ee3eb6
2 changed files with 19 additions and 14 deletions

3
app.py
View file

@ -83,3 +83,6 @@ notification_queue = WorkQueue(app.config['NOTIFICATION_QUEUE_NAME'], tf)
database.configure(app.config) database.configure(app.config)
model.config.app_config = app.config model.config.app_config = app.config
model.config.store = storage model.config.store = storage
def get_app_url():
return '%s://%s' % (app.config['PREFERRED_URL_SCHEME'], app.config['SERVER_HOSTNAME'])

View file

@ -1,33 +1,33 @@
from flask.ext.mail import Message from flask.ext.mail import Message
from app import mail, app from app import mail, app, get_app_url
CONFIRM_MESSAGE = """ CONFIRM_MESSAGE = """
This email address was recently used to register the username '%s' This email address was recently used to register the username '%s'
at <a href="https://quay.io">Quay.io</a>.<br> at <a href="%s">Quay.io</a>.<br>
<br> <br>
To confirm this email address, please click the following link:<br> To confirm this email address, please click the following link:<br>
<a href="https://quay.io/confirm?code=%s">https://quay.io/confirm?code=%s</a> <a href="%s/confirm?code=%s">%s/confirm?code=%s</a>
""" """
CHANGE_MESSAGE = """ CHANGE_MESSAGE = """
This email address was recently asked to become the new e-mail address for username '%s' This email address was recently asked to become the new e-mail address for username '%s'
at <a href="https://quay.io">Quay.io</a>.<br> at <a href="%s">Quay.io</a>.<br>
<br> <br>
To confirm this email address, please click the following link:<br> To confirm this email address, please click the following link:<br>
<a href="https://quay.io/confirm?code=%s">https://quay.io/confirm?code=%s</a> <a href="%s/confirm?code=%s">%s/confirm?code=%s</a>
""" """
RECOVERY_MESSAGE = """ RECOVERY_MESSAGE = """
A user at <a href="https://quay.io">Quay.io</a> has attempted to recover their account A user at <a href="%s">Quay.io</a> has attempted to recover their account
using this email.<br> using this email address.<br>
<br> <br>
If you made this request, please click the following link to recover your account and If you made this request, please click the following link to recover your account and
change your password: change your password:
<a href="https://quay.io/recovery?code=%s">https://quay.io/recovery?code=%s</a><br> <a href="%s/recovery?code=%s">%s/recovery?code=%s</a><br>
<br> <br>
If you did not make this request, your account has not been compromised and the user was If you did not make this request, your account has not been compromised and the user was
not given access. Please disregard this email.<br> not given access. Please disregard this email.<br>
@ -58,10 +58,11 @@ Thanks and have a great day!<br>
AUTH_FORREPO_MESSAGE = """ AUTH_FORREPO_MESSAGE = """
A request has been made to send notifications to this email address for the <a href="https://quay.io">Quay.io</a> repository <a href="https://quay.io/repository/%s/%s">%s/%s</a>. A request has been made to send notifications to this email address for the
<a href="%s">Quay.io</a> repository <a href="%s/repository/%s/%s">%s/%s</a>.
<br> <br>
To confirm this email address, please click the following link:<br> To confirm this email address, please click the following link:<br>
<a href="https://quay.io/authrepoemail?code=%s">https://quay.io/authrepoemail?code=%s</a> <a href="%s/authrepoemail?code=%s">%s/authrepoemail?code=%s</a>
""" """
@ -72,7 +73,7 @@ def send_change_email(username, email, token):
msg = Message('Quay.io email change. Please confirm your email.', msg = Message('Quay.io email change. Please confirm your email.',
sender='support@quay.io', # Why do I need this? sender='support@quay.io', # Why do I need this?
recipients=[email]) 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) mail.send(msg)
@ -80,7 +81,7 @@ def send_confirmation_email(username, email, token):
msg = Message('Welcome to Quay.io! Please confirm your email.', msg = Message('Welcome to Quay.io! Please confirm your email.',
sender='support@quay.io', # Why do I need this? sender='support@quay.io', # Why do I need this?
recipients=[email]) 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) 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.', msg = Message('Quay.io Notification: Please confirm your email.',
sender='support@quay.io', # Why do I need this? sender='support@quay.io', # Why do I need this?
recipients=[email]) 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) mail.send(msg)
@ -96,7 +98,7 @@ def send_recovery_email(email, token):
msg = Message('Quay.io account recovery.', msg = Message('Quay.io account recovery.',
sender='support@quay.io', # Why do I need this? sender='support@quay.io', # Why do I need this?
recipients=[email]) 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) mail.send(msg)