]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Use query function for authentication 2422/head
authorAlexander Moisseev <moiseev@mezonplus.ru>
Wed, 15 Aug 2018 12:03:09 +0000 (15:03 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Wed, 15 Aug 2018 12:03:09 +0000 (15:03 +0300)
interface/js/app/rspamd.js

index 32a1ad297e8f195d8c40a801b544cc0ab5b30157..031a86a86e714f5b9412aefe4f1948f91f140023 100644 (file)
@@ -315,21 +315,15 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
                 return;
             }
 
-            $.ajax({
-                global: false,
-                jsonp: false,
-                dataType: "json",
-                type: "GET",
-                url: "auth",
-                beforeSend: function (xhr) {
-                    xhr.setRequestHeader("Password", password);
+            ui.query("auth", {
+                headers: {
+                    Password: password
                 },
                 success: function (json) {
+                    var data = json[0].data;
                     $("#connectPassword").val("");
-                    if (json.auth === "failed") {
-                        // Is actually never returned by Rspamd
-                    } else {
-                        sessionStorage.setItem("read_only", json.read_only);
+                    if (data.auth === "ok") {
+                        sessionStorage.setItem("read_only", data.read_only);
                         saveCredentials(password);
                         $(dialog).hide();
                         $(backdrop).hide();
@@ -340,7 +334,11 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
                     ui.alertMessage("alert-modal alert-error", jqXHR.statusText);
                     $("#connectPassword").val("");
                     $("#connectPassword").focus();
-                }
+                },
+                params: {
+                    global: false,
+                },
+                server: "local"
             });
         });
     };