Better permission handling in editor

This commit is contained in:
Nick O'Leary
2018-01-12 21:00:11 +00:00
parent bb168d35a8
commit 1204cf1ba0
10 changed files with 240 additions and 111 deletions

View File

@@ -63,7 +63,7 @@ RED.settings = (function () {
if (!hasLocalStorage()) {
return;
}
if (key === "auth_tokens") {
if (key === "auth-tokens") {
localStorage.removeItem(key);
} else {
delete userSettings[key];
@@ -161,23 +161,25 @@ RED.settings = (function () {
}
function saveUserSettings() {
if (pendingSave) {
clearTimeout(pendingSave);
if (RED.user.hasPermission("settings.write")) {
if (pendingSave) {
clearTimeout(pendingSave);
}
pendingSave = setTimeout(function() {
pendingSave = null;
$.ajax({
method: 'POST',
contentType: 'application/json',
url: 'settings/user',
data: JSON.stringify(userSettings),
success: function (data) {
},
error: function(jqXHR,textStatus,errorThrown) {
console.log("Unexpected error saving user settings:",jqXHR.status,textStatus);
}
});
},300);
}
pendingSave = setTimeout(function() {
pendingSave = null;
$.ajax({
method: 'POST',
contentType: 'application/json',
url: 'settings/user',
data: JSON.stringify(userSettings),
success: function (data) {
},
error: function(jqXHR,textStatus,errorThrown) {
console.log("Unexpected error saving user settings:",jqXHR.status,textStatus);
}
});
},300);
}
function theme(property,defaultValue) {