summaryrefslogtreecommitdiff
path: root/js/common.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-03-01 15:24:18 +0300
committerAndrew Dolgov <[email protected]>2021-03-01 15:24:18 +0300
commit6359259dbb1e8d5b569f569a7089abffd9259d30 (patch)
tree69fc8e95b55d4c9ab0e3345e6f52d3c5632f038a /js/common.js
parent320503dd3911de93d059ebe1ba8b96004d8f6b03 (diff)
simplify internal authentication code and bump default algo to SSHA-512
Diffstat (limited to 'js/common.js')
-rwxr-xr-xjs/common.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/js/common.js b/js/common.js
index 1544e6d0b..59231010e 100755
--- a/js/common.js
+++ b/js/common.js
@@ -154,7 +154,7 @@ String.prototype.stripTags = function() {
/* exported xhr */
const xhr = {
- post: function(url, params = {}, complete = undefined) {
+ post: function(url, params = {}, complete = undefined, failed = undefined) {
console.log('xhr.post', '>>>', params);
return new Promise((resolve, reject) => {
@@ -165,6 +165,9 @@ const xhr = {
postData: dojo.objectToQuery(params),
handleAs: "text",
error: function(error) {
+ if (failed != undefined)
+ failed(error);
+
reject(error);
},
load: function(data, ioargs) {
@@ -178,7 +181,7 @@ const xhr = {
);
});
},
- json: function(url, params = {}, complete = undefined) {
+ json: function(url, params = {}, complete = undefined, failed = undefined) {
return new Promise((resolve, reject) =>
this.post(url, params).then((data) => {
let obj = null;
@@ -187,6 +190,10 @@ const xhr = {
obj = JSON.parse(data);
} catch (e) {
console.error("xhr.json", e, xhr);
+
+ if (failed != undefined)
+ failed(e);
+
reject(e);
}
@@ -194,6 +201,10 @@ const xhr = {
if (obj && typeof App != "undefined")
if (!App.handleRpcJson(obj)) {
+
+ if (failed != undefined)
+ failed(obj);
+
reject(obj);
return;
}