diff --git a/public/src/forum/admin/groups.js b/public/src/forum/admin/groups.js index 16283d9150..93de7bdbdc 100644 --- a/public/src/forum/admin/groups.js +++ b/public/src/forum/admin/groups.js @@ -2,7 +2,8 @@ define(function() { var Groups = {}; Groups.init = function() { - var createEl = document.getElementById('create'), + var yourid = templates.get('yourid'), + createEl = document.getElementById('create'), createModal = $('#create-modal'), createSubmitBtn = document.getElementById('create-modal-go'), createNameEl = $('#create-group-name'), @@ -171,15 +172,23 @@ define(function() { groupMembersEl.on('click', 'li[data-uid]', function() { var uid = this.getAttribute('data-uid'), gid = detailsModal.attr('data-gid'); - - bootbox.confirm('Are you sure you want to remove this user?', function(confirm) { - if (confirm){ - socket.emit('admin.groups.leave', { - gid: gid, - uid: uid - }, function(err, data) { - if (!err) { - groupMembersEl.find('li[data-uid="' + uid + '"]').remove(); + + 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) { + if (confirm){ + socket.emit('admin.groups.leave', { + gid: gid, + uid: uid + }, function(err, data) { + if (!err) { + groupMembersEl.find('li[data-uid="' + uid + '"]').remove(); + } + }); } }); } @@ -210,4 +219,4 @@ define(function() { }; return Groups; -}); \ No newline at end of file +}); diff --git a/public/templates/admin/groups.tpl b/public/templates/admin/groups.tpl index 40ceae9669..bd21db2b9f 100644 --- a/public/templates/admin/groups.tpl +++ b/public/templates/admin/groups.tpl @@ -95,4 +95,5 @@ - \ No newline at end of file + + diff --git a/src/routes/admin.js b/src/routes/admin.js index 0b23680cd0..d7c1c7863f 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -429,7 +429,8 @@ var nconf = require('nconf'), expand: true }, function (err, groups) { res.json(200, { - groups: groups + groups: groups, + yourid: req.user.uid }); }); });