From fd6d78cc005a6de6ba9ebc764172e8b4eab9f0f8 Mon Sep 17 00:00:00 2001 From: Josue Kouka Date: Mon, 4 Jan 2016 12:17:38 +0100 Subject: [PATCH] handle form_submit_elt key in login info (#9477) --- README | 5 ++++- mandayejs/do_login.js | 2 +- mandayejs/mandaye/views.py | 3 ++- mandayejs/settings.py | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README b/README index 0a7f9e2..0558267 100644 --- a/README +++ b/README @@ -47,7 +47,6 @@ Example of local_settings.py SITE_DOMAIN = 'example.com' SITE_LOGIN_PATH = '/' - SITE_HOME_PATH = '/profile' # Not required SITE_CA_URL = 'https://myidp/account/' # Citizen account SITE_LOCATORS = [ @@ -101,6 +100,10 @@ Example of local_settings.py 'css': 'css/example_associate.css', 'js': 'js/example_associate.js', } + + # DOM Element used to validate the logon form + # If not provided, default is 'input[type=submit]' + SITE_FORM_SUBMIT_ELT = 'button[type=submit]' # Mellon Settings MELLON_IDENTITY_PROVIDERS = [ diff --git a/mandayejs/do_login.js b/mandayejs/do_login.js index 34e4541..52c8f56 100644 --- a/mandayejs/do_login.js +++ b/mandayejs/do_login.js @@ -57,6 +57,6 @@ page.open(input.address, function() { } } } - $(key).parents('form').find('input[type=submit]').click(); + $(key).parents('form').find(input.form_submit_elt).click(); }, input); }); diff --git a/mandayejs/mandaye/views.py b/mandayejs/mandaye/views.py index bfc5293..5de49d6 100644 --- a/mandayejs/mandaye/views.py +++ b/mandayejs/mandaye/views.py @@ -135,11 +135,12 @@ def post_login_do(request, *args, **kwargs): credentials = get_object_or_404(UserCredentials, user=request.user) site_static_root = os.path.join(getattr(settings, 'STATIC_ROOT'), getattr(settings, 'SITE_STATIC_ROOT_PATH', '')) site_auth_checker = getattr(settings, 'SITE_AUTH_CHECKER', '') + site_form_submit_elt = getattr(settings, 'SITE_FORM_SUBMIT_ELT', 'input[type=submit]') login_info = { 'address': request.build_absolute_uri(settings.SITE_LOGIN_PATH), 'cookies': [], 'locators': [ credentials.to_login_info() ], - 'homepath': getattr(settings, 'SITE_HOME_PATH', '/'), + 'form_submit_elt': site_form_submit_elt, 'auth_checker': os.path.join(site_static_root, site_auth_checker) } logger.debug(login_info) diff --git a/mandayejs/settings.py b/mandayejs/settings.py index f45f9ea..1c3fa02 100644 --- a/mandayejs/settings.py +++ b/mandayejs/settings.py @@ -56,6 +56,7 @@ INSTALLED_APPS = ( 'django.contrib.staticfiles', 'mandayejs.mandaye', 'mandayejs.sites.vincennes', + 'mandayejs.sites.montpellier3m', 'gadjo', 'mellon' ) -- 2.6.4