Commit ccaa3905 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

do not attempt to update privileges if not authorized

parent 4da44009
......@@ -36,6 +36,7 @@ var SbmlParameter = require('./map/data/SbmlParameter');
var SecurityError = require('./SecurityError');
var SessionData = require('./SessionData');
var User = require('./map/data/User');
var PrivilegeType = require('./map/data/PrivilegeType');
var GuiConnector = require('./GuiConnector');
......@@ -1232,9 +1233,17 @@ ServerConnector.updateUser = function (user) {
connectedToLdap: user.isConnectedToLdap()
}
};
return self.sendPatchRequest(self.getUserUrl(queryParams), filterParams).then(function () {
var canModifyPrivileges = false;
return self.sendPatchRequest(self.getUserUrl(queryParams), filterParams).then(function (response) {
canModifyPrivileges = JSON.parse(response).privileges.some(function (privilege) {
return privilege.type === PrivilegeType.USER_MANAGEMENT
|| privilege.type === PrivilegeType.PROJECT_MANAGEMENT;
});
return self.getConfiguration();
}).then(function (configuration) {
if (!canModifyPrivileges) {
return Promise.resolve();
}
return self.updateUserPrivileges({user: user, privileges: user.privilegesToExport(configuration)});
});
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment