Fixes #1223 - Do not allow to drop user from non-super user.

Also - fixed some javascript variable scope issue in the 'delete_obj'
function of nodes.
pull/3/head
Murtuza Zabuawala 2016-06-03 15:31:47 +05:30 committed by Ashesh Vashi
parent 1bd37d1f76
commit 9436542074
2 changed files with 21 additions and 6 deletions

View File

@ -297,7 +297,22 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Backform) {
dialogHelp: '{{ url_for('help.static', filename='role_dialog.html') }}',
label: '{{ _('Login/Group Role') }}',
hasSQL: true,
canDrop: true,
canDrop: function(node, item) {
var treeData = this.getTreeNodeHierarchy(item),
server = treeData['server'];
/*
To Drop a role:
1) If Role we are deleting is superuser then User must be superuser
2) And for non-superuser roles User must have Create Role permission
*/
// Role you are trying to drop is Superuser ?
if(node.is_superuser) {
return server.connected && server.user.is_superuser;
}
// For non super users
return server.connected && server.user.can_create_role;
},
hasDepends: true,
node_label: function(r) {
return r.label;

View File

@ -478,11 +478,11 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
},
// Delete the selected object
delete_obj: function(args, item) {
var input = args || {'url':'drop'};
obj = this,
t = pgBrowser.tree,
i = input.item || item || t.selected(),
d = i && i.length == 1 ? t.itemData(i) : undefined;
var input = args || {'url':'drop'},
obj = this,
t = pgBrowser.tree,
i = input.item || item || t.selected(),
d = i && i.length == 1 ? t.itemData(i) : undefined;
if (!d)
return;