multitenant: add portal slug in idp_registration_url (#46729)
This commit is contained in:
parent
1f9e5a5a69
commit
96f78fc0c7
|
@ -141,6 +141,7 @@ class TemplateVars(FileBaseSettingsLoader):
|
|||
if 'portal-user' in service.get('template_name', ''):
|
||||
variables['portal_user_url'] = service.get('base_url')
|
||||
variables['portal_user_title'] = service.get('title')
|
||||
variables['portal_user_slug'] = service.get('slug')
|
||||
|
||||
if service.get('service-id') == 'authentic':
|
||||
variables['idp_url'] = service.get('base_url')
|
||||
|
@ -157,8 +158,14 @@ class TemplateVars(FileBaseSettingsLoader):
|
|||
if 'portal-agent' in service.get('template_name', ''):
|
||||
variables['is_portal_agent'] = True
|
||||
|
||||
if 'portal_user_url' in variables and 'idp_registration_url' in variables:
|
||||
variables['idp_registration_url'] += '?%s' % urlencode({'next': variables['portal_user_url']})
|
||||
if 'idp_registration_url' in variables:
|
||||
params = {}
|
||||
if 'portal_user_url' in variables:
|
||||
params['next'] = variables['portal_user_url']
|
||||
if 'portal_user_slug' in variables:
|
||||
params['service'] = variables['portal_user_slug']
|
||||
if params:
|
||||
variables['idp_registration_url'] += '?%s' % urlencode(params)
|
||||
|
||||
if getattr(settings, 'HOBO_MANAGER_HOMEPAGE_TITLE_VAR', None):
|
||||
variables['manager_homepage_title'] = \
|
||||
|
|
|
@ -143,3 +143,20 @@ def test_sms_update_settings_from_path(tmpdir):
|
|||
loader.update_settings_from_path(tenant_settings, path)
|
||||
assert tenant_settings.SMS_URL == 'https://example.com/send/'
|
||||
assert tenant_settings.SMS_SENDER == 'Sender'
|
||||
|
||||
|
||||
def test_get_hobo_json_variables(tmpdir):
|
||||
a = Authentic(title='bar', slug='bar', base_url='http://bar.example.net')
|
||||
a.save()
|
||||
c = Combo(title='combo', slug='portal', base_url='http://portal.example.net', template_name='portal-user')
|
||||
c.save()
|
||||
|
||||
loader = TemplateVars()
|
||||
env = get_hobo_json()
|
||||
|
||||
variables = loader.get_hobo_json_variables(env)
|
||||
|
||||
url = variables['idp_registration_url']
|
||||
assert url.startswith('http://bar.example.net/accounts/register/?')
|
||||
assert 'next=http%3A%2F%2Fportal.example.net%2F' in url
|
||||
assert 'service=portal' in url
|
||||
|
|
Loading…
Reference in New Issue