From: Frank Naegler Date: Fri, 14 Oct 2016 13:41:29 +0000 (+0200) Subject: [BUGFIX] Remove dependency to RsaEncryptionModule in LoginRefresh X-Git-Tag: TYPO3_8-4-0~17 X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/commitdiff_plain/5a568ed2f9e93e562948019c5b14db04e9a736b1 [BUGFIX] Remove dependency to RsaEncryptionModule in LoginRefresh This patch removes the hard dependency to RsaEncryptionModule and adds a check if the module can be loaded. It on the go adds a hardening to the RsaEncryptionModule to avoid registration of form event handlers twice, which is now needed to cover all potential loading orders of RsaEncryptionModule and LoginRefresh. Resolves: #78299 Related: #75911 Releases: master, 7.6 Change-Id: Ie03f1c7bc34e48f03213dec70c62d8ccc339ab31 Reviewed-on: https://review.typo3.org/50229 Tested-by: TYPO3com Reviewed-by: Markus Klein Reviewed-by: Nicole Cordes Tested-by: Nicole Cordes Reviewed-by: Frank Naegler Tested-by: Frank Naegler Reviewed-by: Stefan Neufeind Tested-by: Stefan Neufeind --- diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/LoginRefresh.js b/typo3/sysext/backend/Resources/Public/JavaScript/LoginRefresh.js index 7cc48273f4f9..d8fde70d7277 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/LoginRefresh.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/LoginRefresh.js @@ -16,7 +16,7 @@ * Task that periodically checks if a blocking event in the backend occurred and * displays a proper dialog to the user. */ -define(['jquery', 'TYPO3/CMS/Backend/Notification', 'TYPO3/CMS/Rsaauth/RsaEncryptionModule', 'bootstrap'], function($, Typo3Notification, RsaEncryption) { +define(['jquery', 'TYPO3/CMS/Backend/Notification', 'bootstrap'], function($, Typo3Notification) { 'use strict'; /** @@ -237,13 +237,13 @@ define(['jquery', 'TYPO3/CMS/Backend/Notification', 'TYPO3/CMS/Rsaauth/RsaEncryp LoginRefresh.$loginForm.find('form').submit(); }) ); - var $LoginRefreshForm = LoginRefresh.$loginForm.find('#beLoginRefresh'); - if (undefined !== RsaEncryption) { - RsaEncryption.registerForm($LoginRefreshForm.get(0)); - } - LoginRefresh.registerDefaultModalEvents($LoginRefreshForm).on('submit', LoginRefresh.submitForm); - + LoginRefresh.registerDefaultModalEvents(LoginRefresh.$loginForm).on('submit', LoginRefresh.submitForm); $('body').append(LoginRefresh.$loginForm); + if (require.specified('TYPO3/CMS/Rsaauth/RsaEncryptionModule')) { + require(['TYPO3/CMS/Rsaauth/RsaEncryptionModule'], function(RsaEncryption) { + RsaEncryption.registerForm($('#beLoginRefresh').get(0)); + }); + } }; /** diff --git a/typo3/sysext/rsaauth/Resources/Public/JavaScript/RsaEncryptionModule.js b/typo3/sysext/rsaauth/Resources/Public/JavaScript/RsaEncryptionModule.js index a6c5646bb66e..41eb330355b3 100644 --- a/typo3/sysext/rsaauth/Resources/Public/JavaScript/RsaEncryptionModule.js +++ b/typo3/sysext/rsaauth/Resources/Public/JavaScript/RsaEncryptionModule.js @@ -42,6 +42,13 @@ define(['jquery', './RsaLibrary'], function($) { registerForm: function(form) { var $form = $(form); + if ($form.data('rsaRegistered')) { + // Do not register form twice + return; + } + // Mark form as registered + $form.data('rsaRegistered', true); + // Store the original submit handler that is executed later $form.data('original-onsubmit', $form.attr('onsubmit'));