mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-06-15 23:50:21 +02:00
closes #2315
This commit is contained in:
@@ -124,6 +124,20 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.password-reset-email').on('click', function() {
|
||||
var uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
bootbox.confirm('Do you want to send password reset email(s) to these user(s)?', function(confirm) {
|
||||
if (confirm) {
|
||||
socket.emit('admin.user.sendPasswordResetEmail', uids, done('Emails sent'));
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.delete-user').on('click', function() {
|
||||
var uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
|
||||
@@ -36,21 +36,25 @@ Emailer.send = function(template, uid, params) {
|
||||
next(undefined, translated);
|
||||
});
|
||||
}, function(err, translated) {
|
||||
if(err) {
|
||||
if (err) {
|
||||
return winston.error(err.message);
|
||||
} else if (!results.email) {
|
||||
return winston.warn('uid : ' + uid + ' has no email, not sending.');
|
||||
}
|
||||
|
||||
Plugins.fireHook('action:email.send', {
|
||||
to: results.email,
|
||||
from: meta.config['email:from'] || 'no-reply@localhost.lan',
|
||||
subject: translated[2],
|
||||
html: translated[0],
|
||||
plaintext: translated[1],
|
||||
template: template,
|
||||
uid: uid
|
||||
});
|
||||
if (Plugins.hasListeners('action:email.send')) {
|
||||
Plugins.fireHook('action:email.send', {
|
||||
to: results.email,
|
||||
from: meta.config['email:from'] || 'no-reply@localhost.lan',
|
||||
subject: translated[2],
|
||||
html: translated[0],
|
||||
plaintext: translated[1],
|
||||
template: template,
|
||||
uid: uid
|
||||
});
|
||||
} else {
|
||||
winston.warn('[emailer] No active email plugin found!');
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -118,6 +118,28 @@ User.validateEmail = function(socket, uids, callback) {
|
||||
}, callback);
|
||||
};
|
||||
|
||||
User.sendPasswordResetEmail = function(socket, uids, callback) {
|
||||
if (!Array.isArray(uids)) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
uids = uids.filter(function(uid) {
|
||||
return parseInt(uid, 10);
|
||||
});
|
||||
|
||||
async.each(uids, function(uid, next) {
|
||||
user.getUserFields(uid, ['email', 'username'], function(err, userData) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (!userData.email) {
|
||||
return next(new Error('[[error:user-doesnt-have-email, ' + userData.username + ']]'));
|
||||
}
|
||||
user.reset.send(userData.email, next);
|
||||
});
|
||||
}, callback);
|
||||
};
|
||||
|
||||
User.deleteUsers = function(socket, uids, callback) {
|
||||
if(!Array.isArray(uids)) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<li><a href="#" class="remove-admin-user"><i class="fa fa-fw fa-ban"></i> Remove Admin</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="#" class="validate-email"><i class="fa fa-fw fa-check"></i> Validate Email</a></li>
|
||||
<li><a href="#" class="password-reset-email"><i class="fa fa-fw fa-key"></i> Send Password Reset Email</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="#" class="ban-user"><i class="fa fa-fw fa-gavel"></i> Ban User</a></li>
|
||||
<li><a href="#" class="unban-user"><i class="fa fa-fw fa-comment-o"></i> Unban User</a></li>
|
||||
|
||||
Reference in New Issue
Block a user