Merge pull request #828 from BitBangersCode/admin-group-fix

Admin group fix
v1.18.x
Barış Soner Uşaklı 11 years ago
commit c709fae251

@ -2,7 +2,8 @@ define(function() {
var Groups = {}; var Groups = {};
Groups.init = function() { Groups.init = function() {
var createEl = document.getElementById('create'), var yourid = templates.get('yourid'),
createEl = document.getElementById('create'),
createModal = $('#create-modal'), createModal = $('#create-modal'),
createSubmitBtn = document.getElementById('create-modal-go'), createSubmitBtn = document.getElementById('create-modal-go'),
createNameEl = $('#create-group-name'), createNameEl = $('#create-group-name'),
@ -172,6 +173,12 @@ define(function() {
var uid = this.getAttribute('data-uid'), var uid = this.getAttribute('data-uid'),
gid = detailsModal.attr('data-gid'); gid = detailsModal.attr('data-gid');
socket.emit('admin.groups.get', gid, function(err, groupObj){
if (!err){
if (groupObj.name == 'Administrators' && uid == yourid){
bootbox.alert('You cannot remove yourself from the Administrator Group');
return;
}
bootbox.confirm('Are you sure you want to remove this user?', function(confirm) { bootbox.confirm('Are you sure you want to remove this user?', function(confirm) {
if (confirm){ if (confirm){
socket.emit('admin.groups.leave', { socket.emit('admin.groups.leave', {
@ -184,6 +191,8 @@ define(function() {
}); });
} }
}); });
}
});
}); });
detailsModalSave.on('click', function() { detailsModalSave.on('click', function() {

@ -96,3 +96,4 @@
</div> </div>
</div> </div>
</div> </div>
<input type="hidden" template-variable="yourid" value="{yourid}" />

@ -429,7 +429,8 @@ var nconf = require('nconf'),
expand: true expand: true
}, function (err, groups) { }, function (err, groups) {
res.json(200, { res.json(200, {
groups: groups groups: groups,
yourid: req.user.uid
}); });
}); });
}); });

Loading…
Cancel
Save