mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 17:15:55 +00:00
simplify internal authentication code and bump default algo to SSHA-512
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
'use strict'
|
||||
|
||||
/* global __ */
|
||||
/* global xhrPost, xhr, dijit, Notify, Tables, App, fox */
|
||||
/* global __, xhr, dijit, Notify, Tables, App, fox */
|
||||
|
||||
const Users = {
|
||||
reload: function(sort) {
|
||||
const user_search = App.byId("user_search");
|
||||
const search = user_search ? user_search.value : "";
|
||||
return new Promise((resolve, reject) => {
|
||||
const user_search = App.byId("user_search");
|
||||
const search = user_search ? user_search.value : "";
|
||||
|
||||
xhr.post("backend.php", { op: "pref-users", sort: sort, search: search }, (reply) => {
|
||||
dijit.byId('usersTab').attr('content', reply);
|
||||
Notify.close();
|
||||
xhr.post("backend.php", { op: "pref-users", sort: sort, search: search }, (reply) => {
|
||||
dijit.byId('usersTab').attr('content', reply);
|
||||
Notify.close();
|
||||
resolve();
|
||||
}, (e) => { reject(e) });
|
||||
});
|
||||
},
|
||||
add: function() {
|
||||
@@ -20,8 +22,9 @@ const Users = {
|
||||
Notify.progress("Adding user...");
|
||||
|
||||
xhr.post("backend.php", {op: "pref-users", method: "add", login: login}, (reply) => {
|
||||
alert(reply);
|
||||
Users.reload();
|
||||
Users.reload().then(() => {
|
||||
Notify.info(reply);
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
@@ -38,9 +41,11 @@ const Users = {
|
||||
if (this.validate()) {
|
||||
Notify.progress("Saving data...", true);
|
||||
|
||||
xhr.post("backend.php", this.attr('value'), () => {
|
||||
xhr.post("backend.php", this.attr('value'), (reply) => {
|
||||
dialog.hide();
|
||||
Users.reload();
|
||||
Users.reload().then(() => {
|
||||
Notify.info(reply);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
15
js/common.js
15
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user