mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-04 03:21:18 +01:00
Merge pull request #4317 from samhax/delete-user-invites
Delete user invites from APM
This commit is contained in:
@@ -8,7 +8,6 @@ define('admin/manage/registration', function() {
|
||||
Registration.init = function() {
|
||||
|
||||
$('.users-list').on('click', '[data-action]', function(ev) {
|
||||
var $this = this;
|
||||
var parent = $(this).parents('[data-username]');
|
||||
var action = $(this).attr('data-action');
|
||||
var username = parent.attr('data-username');
|
||||
@@ -22,6 +21,37 @@ define('admin/manage/registration', function() {
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.invites-list').on('click', '[data-action]', function(ev) {
|
||||
var parent = $(this).parents('[data-invitation-mail][data-invited-by]');
|
||||
var email = parent.attr('data-invitation-mail');
|
||||
var invitedBy = parent.attr('data-invited-by');
|
||||
var action = $(this).attr('data-action');
|
||||
var method = 'admin.user.deleteInvitation';
|
||||
|
||||
var removeRow = function () {
|
||||
var nextRow = parent.next(),
|
||||
thisRowinvitedBy = parent.find('.invited-by'),
|
||||
nextRowInvitedBy = nextRow.find('.invited-by');
|
||||
if (nextRowInvitedBy.html() !== undefined && nextRowInvitedBy.html().length < 2) {
|
||||
nextRowInvitedBy.html(thisRowinvitedBy.html());
|
||||
}
|
||||
parent.remove();
|
||||
};
|
||||
if (action === 'delete') {
|
||||
bootbox.confirm('Are you sure you wish to delete this invitation?', function(confirm) {
|
||||
if (confirm) {
|
||||
socket.emit(method, {email: email, invitedBy: invitedBy}, function(err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
removeRow();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
return Registration;
|
||||
|
||||
@@ -93,7 +93,7 @@ function registerAndLoginUser(req, res, userData, callback) {
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
user.deleteInvitation(userData.email);
|
||||
user.deleteInvitationKey(userData.email);
|
||||
plugins.fireHook('filter:register.complete', {uid: uid, referrer: req.body.referrer || nconf.get('relative_path') + '/'}, next);
|
||||
}
|
||||
], callback);
|
||||
|
||||
@@ -212,6 +212,10 @@ User.search = function(socket, data, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
User.deleteInvitation = function(socket, data, callback) {
|
||||
user.deleteInvitation(data.invitedBy, data.email, callback);
|
||||
};
|
||||
|
||||
User.acceptRegistration = function(socket, data, callback) {
|
||||
user.acceptRegistration(data.username, callback);
|
||||
};
|
||||
@@ -221,4 +225,4 @@ User.rejectRegistration = function(socket, data, callback) {
|
||||
};
|
||||
|
||||
|
||||
module.exports = User;
|
||||
module.exports = User;
|
||||
|
||||
@@ -39,7 +39,6 @@ var async = require('async'),
|
||||
if (err || userData.status === 'offline' || now - parseInt(userData.lastonline, 10) < 300000) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
User.setUserField(uid, 'lastonline', now, callback);
|
||||
});
|
||||
};
|
||||
@@ -257,4 +256,3 @@ var async = require('async'),
|
||||
|
||||
|
||||
}(exports));
|
||||
|
||||
|
||||
@@ -120,7 +120,31 @@ module.exports = function(User) {
|
||||
], callback);
|
||||
};
|
||||
|
||||
User.deleteInvitation = function(email, callback) {
|
||||
User.deleteInvitation = function(invitedBy, email, callback) {
|
||||
callback = callback || function() {};
|
||||
async.waterfall([
|
||||
function getInvitedByUid(next) {
|
||||
User.getUidByUsername(invitedBy, next);
|
||||
},
|
||||
function deleteRegistries(invitedByUid, next) {
|
||||
if (!invitedByUid) {
|
||||
return next(new Error('[[error:invalid-username]]'));
|
||||
}
|
||||
async.parallel([
|
||||
function deleteFromReferenceList(next) {
|
||||
db.setRemove('invitation:uid:' + invitedByUid, email, next);
|
||||
},
|
||||
function deleteInviteKey(next) {
|
||||
db.delete('invitation:email:' + email, callback);
|
||||
}
|
||||
], function(err) {
|
||||
next(err)
|
||||
});
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
User.deleteInvitationKey = function(email, callback) {
|
||||
callback = callback || function() {};
|
||||
db.delete('invitation:email:' + email, callback);
|
||||
};
|
||||
|
||||
@@ -66,18 +66,23 @@
|
||||
<br><br>
|
||||
The username will be displayed to the right of the emails for users who have redeemed their invitations.
|
||||
</p>
|
||||
<table class="table table-striped users-list">
|
||||
<table class="table table-striped invites-list">
|
||||
<tr>
|
||||
<th>Inviter Username</th>
|
||||
<th>Invitee Email</th>
|
||||
<th>Invitee Username (if registered)</th>
|
||||
</tr>
|
||||
<!-- BEGIN invites -->
|
||||
<tr>
|
||||
<!-- BEGIN invites.invitations -->
|
||||
<td><!-- IF @first -->{invites.username}<!-- ENDIF @first --></td>
|
||||
<!-- BEGIN invites.invitations -->
|
||||
<tr data-invitation-mail="{invites.invitations.email}"
|
||||
data-invited-by="{invites.username}">
|
||||
<td class ="invited-by"><!-- IF @first -->{invites.username}<!-- ENDIF @first --></td>
|
||||
<td>{invites.invitations.email}</td>
|
||||
<td>{invites.invitations.username}</td>
|
||||
<td>{invites.invitations.username}
|
||||
<div class="btn-group pull-right">
|
||||
<button class="btn btn-danger btn-xs" data-action="delete"><i class="fa fa-times"></i></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- END invites.invitations -->
|
||||
<!-- END invites -->
|
||||
|
||||
Reference in New Issue
Block a user