Allow admin to specify domain for email auth links

Similar to https://github.com/alphagov/notifications-api/pull/1515

This lets the admin app pass in a domain to use for email auth links,
so that when it’s running on a different URL users who try to sign in
will get an email auth link for the domain they sign in on, not the
default admin domain for the environment in which the API is running.
This commit is contained in:
Chris Hill-Scott
2018-02-09 14:16:10 +00:00
parent bb027a5d8c
commit c0e2a478f6
4 changed files with 29 additions and 9 deletions

View File

@@ -20,10 +20,10 @@ def pagination_links(pagination, endpoint, **kwargs):
return links
def url_with_token(data, url, config):
def url_with_token(data, url, config, base_url=None):
from notifications_utils.url_safe_token import generate_token
token = generate_token(data, config['SECRET_KEY'], config['DANGEROUS_SALT'])
base_url = config['ADMIN_BASE_URL'] + url
base_url = (base_url or config['ADMIN_BASE_URL']) + url
return base_url + token