[BUGFIX] Remove dependency to RsaEncryptionModule in LoginRefresh 39/50239/2
authorFrank Naegler <frank.naegler@typo3.org>
Fri, 14 Oct 2016 13:41:29 +0000 (15:41 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 31 Oct 2016 22:26:40 +0000 (23:26 +0100)
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/50239
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Resources/Public/JavaScript/LoginRefresh.js
typo3/sysext/rsaauth/Resources/Public/JavaScript/RsaEncryptionModule.js

index 7cc4827..d8fde70 100644 (file)
@@ -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));
+                       });
+               }
        };
 
        /**
index a6c5646..41eb330 100644 (file)
@@ -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'));