]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7761 improve submitting of login form
authorStas Vilchik <vilchiks@gmail.com>
Fri, 24 Jun 2016 09:43:52 +0000 (11:43 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 29 Jun 2016 06:39:32 +0000 (08:39 +0200)
server/sonar-web/src/main/js/libs/application.js
server/sonar-web/src/main/webapp/WEB-INF/app/views/sessions/_form.html.erb

index 43a1492ca2df257580c42dde389de993fafbc372..95e2b9685d57229fa77bb5016f290630045f6f4a 100644 (file)
@@ -187,7 +187,7 @@ function openModalWindow (url, options) {
       return this.each(function () {
         var obj = jQuery(this);
         obj.submit(function () {
-          jQuery('input[type=submit]', this).attr('disabled', 'disabled');
+          jQuery('input[type=submit], button', this).attr('disabled', 'disabled');
           jQuery.ajax(jQuery.extend({
             type: 'POST',
             url: obj.attr('action'),
@@ -202,7 +202,7 @@ function openModalWindow (url, options) {
                 // Hide all loading images
                 jQuery('.loading-image').addClass('hidden');
                 // Re activate submit button
-                jQuery('input[type=submit]', obj).removeAttr('disabled');
+                jQuery('input[type=submit], button', obj).removeAttr('disabled');
                 errorElt.show();
                 errorElt.html(jQuery('<div/>').html(xhr.responseText).text());
               } else {
index 26a6e7378dc1e37beec39e7884d5b766d1a424e1..4495fffa997fc709b34ac21fa9a9025909b2416b 100644 (file)
     if (!returnToAnchor.val()) {
       returnToAnchor.val(window.location.hash);
     }
-  })(window.jQuery);
 
-  $j("#login_form").modalForm({
-    success: function () {
-      window.location = '<%= ApplicationController.root_context + h(@return_to) -%>' + $j('[name="return_to_anchor"]').val();
-    },
-    error: function () {
-      jQuery('.alert').removeClass('hidden');
-    }
-  });
+    $("#login_form").modalForm({
+      success: function () {
+        window.location = '<%= h(@return_to) -%>' + $('[name="return_to_anchor"]').val();
+      },
+      error: function () {
+        $('.alert').removeClass('hidden');
+        $('button').prop('disabled', false);
+      },
+      statusCode: {
+        401: null
+      }
+    });
+  })(window.jQuery);
 </script>