fix error handling and displaying on membership PUT and DELETE; don't allow to change your own role; require at least one admin

This commit is contained in:
mntmn
2020-04-09 14:55:18 +02:00
parent c05afaba8a
commit 16ffecdb16
4 changed files with 57 additions and 21 deletions

View File

@@ -776,9 +776,12 @@ var SpacedeckSpaces = {
this.invite_message = "";
}
}.bind(this), function(xhr){
text = JSON.stringify(xhr.responseText);
smoke.alert("Error: "+text);
try {
var res = JSON.parse(xhr.response);
alert("Error: "+res.error);
} catch (e) {
console.error(e, xhr);
}
}.bind(this));
}.bind(this));
},
@@ -786,9 +789,13 @@ var SpacedeckSpaces = {
update_member: function(space, m, role) {
m.role = role;
save_membership(space, m, function() {
console.log("saved")
}.bind(this), function(xhr) {
console.error(xhr);
try {
var res = JSON.parse(xhr.response);
alert("Error: "+res.error);
} catch (e) {
console.error(e, xhr);
}
}.bind(this));
},
@@ -797,7 +804,12 @@ var SpacedeckSpaces = {
delete_membership(space, m, function() {
this.access_settings_memberships.splice(this.access_settings_memberships.indexOf(m), 1);
}.bind(this), function(xhr) {
console.error(xhr);
try {
var res = JSON.parse(xhr.response);
alert("Error: "+res.error);
} catch (e) {
console.error(e, xhr);
}
}.bind(this));
},