make sure old invites get the proper message

we were accidentally covering up the expiry message with a more
generic one
This commit is contained in:
Leo Hemsted
2017-11-02 13:49:24 +00:00
parent 5e175954d2
commit 04adb15e85
3 changed files with 35 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ from flask import (
abort,
current_app
)
from itsdangerous import SignatureExpired
from markupsafe import Markup
from notifications_utils.url_safe_token import check_token
from flask_login import current_user
@@ -21,12 +22,20 @@ from app import (
@main.route("/invitation/<token>")
def accept_invite(token):
check_token(
token,
current_app.config['SECRET_KEY'],
current_app.config['DANGEROUS_SALT'],
current_app.config['EMAIL_EXPIRY_SECONDS']
)
try:
check_token(
token,
current_app.config['SECRET_KEY'],
current_app.config['DANGEROUS_SALT'],
current_app.config['INVITATION_EXPIRY_SECONDS']
)
except SignatureExpired:
errors = [
'Your invitation to GOV.UK Notify has expired. '
'Please ask the person that invited you to send you another one'
]
return render_template("error/400.html", message=errors), 400
invited_user = invite_api_client.check_token(token)
if not current_user.is_anonymous and current_user.email_address != invited_user.email_address: