login: add an option to hide cancel button (#41122)
This commit is contained in:
parent
10625bcaf4
commit
1e6831256b
|
@ -311,6 +311,10 @@ default_settings = dict(
|
|||
A2_LOGIN_REDIRECT_AUTHENTICATED_USERS_TO_HOMEPAGE=Setting(
|
||||
default=False,
|
||||
definition='Redirect authenticated users to homepage'),
|
||||
A2_LOGIN_DISPLAY_A_CANCEL_BUTTON=Setting(
|
||||
default=False,
|
||||
definition='Display a cancel button.'
|
||||
'This is only applicable for Liberty single sign on requests'),
|
||||
A2_SET_RANDOM_PASSWORD_ON_RESET=Setting(
|
||||
default=True,
|
||||
definition='Set a random password on request to reset the password from the front-office'),
|
||||
|
|
|
@ -278,7 +278,7 @@ def login(request, template_name='authentic2/login.html',
|
|||
registration_url = utils.get_registration_url(request, service=service)
|
||||
|
||||
context = {
|
||||
'cancel': nonce is not None,
|
||||
'cancel': app_settings.A2_LOGIN_DISPLAY_A_CANCEL_BUTTON and nonce is not None,
|
||||
'can_reset_password': app_settings.A2_USER_CAN_RESET_PASSWORD is not False,
|
||||
'registration_authorized': getattr(settings, 'REGISTRATION_OPEN', True),
|
||||
'registration_url': registration_url,
|
||||
|
|
|
@ -52,6 +52,7 @@ from . import utils
|
|||
@pytest.fixture
|
||||
def saml_settings(settings):
|
||||
settings.A2_IDP_SAML2_ENABLE = True
|
||||
settings.A2_LOGIN_DISPLAY_A_CANCEL_BUTTON = True
|
||||
|
||||
|
||||
def get_idp_metadata(app):
|
||||
|
|
|
@ -236,3 +236,12 @@ def test_views_email_token_resend(app, simple_user, settings, mailoutbox, view_n
|
|||
# validating again anyway works
|
||||
response = response.form.submit()
|
||||
assert len(mailoutbox) == 2
|
||||
|
||||
|
||||
def test_views_login_display_a_cancel_button(app, settings):
|
||||
response = app.get(reverse('auth_login'), params={'next': '/foo/', 'nonce': 'xxx'})
|
||||
assert not response.html.find('button', {'class': 'cancel-button'})
|
||||
|
||||
settings.A2_LOGIN_DISPLAY_A_CANCEL_BUTTON = True
|
||||
response = app.get(reverse('auth_login'), params={'next': '/foo/', 'nonce': 'xxx'})
|
||||
assert response.html.find('button', {'class': 'cancel-button'})
|
||||
|
|
Loading…
Reference in New Issue