misc: always add service variables to login condition context (#60125)
This commit is contained in:
parent
4e97acc419
commit
c95fe470a4
|
@ -350,6 +350,10 @@ def login(request, template_name='authentic2/login.html', redirect_field_name=RE
|
|||
show_ctx['service_ou_slug'] = service.ou and service.ou.slug
|
||||
show_ctx['service_slug'] = service.slug
|
||||
show_ctx['service'] = service
|
||||
else:
|
||||
show_ctx['service_ou_slug'] = ''
|
||||
show_ctx['service_slug'] = ''
|
||||
show_ctx['service'] = None
|
||||
# check if the authenticator has multiple instances
|
||||
if hasattr(authenticator, 'instances'):
|
||||
for instance_id, instance in authenticator.instances(**parameters):
|
||||
|
|
|
@ -87,8 +87,12 @@ def test_show_condition(db, app, settings, caplog):
|
|||
|
||||
def test_show_condition_service(db, app, settings):
|
||||
settings.AUTH_FRONTENDS_KWARGS = {'password': {'show_condition': 'service_slug == \'portal\''}}
|
||||
response = app.get('/login/', params={})
|
||||
assert 'name="login-password-submit"' not in response
|
||||
|
||||
# service doesn't exist
|
||||
response = app.get('/login/', params={'service': 'portal'})
|
||||
assert 'name="login-password-submit"' in response
|
||||
assert 'name="login-password-submit"' not in response
|
||||
|
||||
# Create a service
|
||||
models.Service.objects.create(name='Service', slug='portal')
|
||||
|
|
Loading…
Reference in New Issue