]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Fix various errors with login form
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 30 Jan 2017 14:08:53 +0000 (14:08 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 30 Jan 2017 14:16:43 +0000 (14:16 +0000)
interface/js/rspamd.js

index 52cd93cabd25b7e907f0592e641b32edb9cdd8fb..0b386afb1031e989163aa3d01b971e518c5c2e45 100644 (file)
             });
         }
         // @upload edited actions
-        $(document).on('submit', '#actionsForm', function () {
+        $('#actionsForm').on('submit', function () {
             var inputs = $('#actionsForm :input[type="slider"]');
             var url = 'saveactions';
             var values = [];
                 displayUI();
                 return;
             }
+
             var nav = $('#navBar');
             var ui = $('#mainUI');
             var dialog = $('#connectDialog');
             var disconnect = $('#navBar .pull-right');
             $(ui).hide();
             $(dialog).show();
-            $('#connectHost').focus();
             $(backdrop).show();
-            document.getElementById("connectPassword").focus();
-            $('#connectForm').one('submit', function (e) {
+            $('#connectPassword').focus();
+            $('#connectForm').off('submit');
+
+            $('#connectForm').on('submit', function (e) {
                 e.preventDefault();
                 var password = $('#connectPassword').val();
-                document.getElementById('connectPassword').value = '';
+                if (!/^[\u0000-\u007f]*$/.test(password)) {
+                    alertMessage('alert-modal alert-error', 'Invalid characters in the password');
+                    $('#connectPassword').focus();
+                    return;
+                }
+
                 $.ajax({
                     global: false,
                     jsonp: false,
                         xhr.setRequestHeader('Password', password);
                     },
                     success: function (data) {
+                        $('#connectPassword').val('');
                         if (data.auth === 'failed') {
-                            $(form).each(function () {
-                                $('.form-group').addClass('error');
-                            });
+                            // Is actually never returned by Rspamd
                         } else {
                             if (data.read_only) {
                                 read_only = true;
                     },
                     error: function (data) {
                         alertMessage('alert-modal alert-error', data.statusText);
+                        $('#connectPassword').val('');
+                        $('#connectPassword').focus();
                     }
                 });
             });