mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-12 00:45:47 +01:00
updated groups to stop you from removing yourself from the admin group
This commit is contained in:
@@ -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,18 +173,26 @@ define(function() {
|
|||||||
var uid = this.getAttribute('data-uid'),
|
var uid = this.getAttribute('data-uid'),
|
||||||
gid = detailsModal.attr('data-gid');
|
gid = detailsModal.attr('data-gid');
|
||||||
|
|
||||||
bootbox.confirm('Are you sure you want to remove this user?', function(confirm) {
|
socket.emit('admin.groups.get', gid, function(err, groupObj){
|
||||||
if (confirm){
|
if (!err){
|
||||||
socket.emit('admin.groups.leave', {
|
if (groupObj.name == 'Administrators' && uid == yourid){
|
||||||
gid: gid,
|
bootbox.alert('You cannot remove yourself from the Administrator Group');
|
||||||
uid: uid
|
return;
|
||||||
}, function(err, data) {
|
}
|
||||||
if (!err) {
|
bootbox.confirm('Are you sure you want to remove this user?', function(confirm) {
|
||||||
groupMembersEl.find('li[data-uid="' + uid + '"]').remove();
|
if (confirm){
|
||||||
}
|
socket.emit('admin.groups.leave', {
|
||||||
});
|
gid: gid,
|
||||||
|
uid: uid
|
||||||
|
}, function(err, data) {
|
||||||
|
if (!err) {
|
||||||
|
groupMembersEl.find('li[data-uid="' + uid + '"]').remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
detailsModalSave.on('click', function() {
|
detailsModalSave.on('click', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user