v1.18.x
Barış Soner Uşaklı 10 years ago
parent 7d963e52cf
commit 3293436867

@ -134,6 +134,19 @@ define('admin/manage/users', ['admin/modules/selectable'], function(selectable)
return false;
});
$('.send-validation-email').on('click', function() {
var uids = getSelectedUids();
if (!uids.length) {
return;
}
socket.emit('admin.user.sendValidationEmail', uids, function(err) {
if (err) {
return app.alertError(err.message);
}
app.alertSuccess('[[notifications:email-confirm-sent]]');
});
})
$('.password-reset-email').on('click', function() {
var uids = getSelectedUids();
if (!uids.length) {

@ -64,6 +64,7 @@ var fs = require('fs'),
uid: uid,
pid: params.pid
});
callback();
} else {
winston.warn('[emailer] No active email plugin found!');
callback();

@ -1,12 +1,13 @@
"use strict";
var db = require('../../database'),
var async = require('async'),
db = require('../../database'),
groups = require('../../groups'),
user = require('../../user'),
events = require('../../events'),
meta = require('../../meta'),
websockets = require('../index'),
async = require('async'),
User = {};
@ -127,6 +128,30 @@ User.validateEmail = function(socket, uids, callback) {
}, callback);
};
User.sendValidationEmail = function(socket, uids, callback) {
if (!Array.isArray(uids)) {
return callback(new Error('[[error:invalid-data]]'));
}
if (parseInt(meta.config.requireEmailConfirmation, 10) !== 1) {
return callback(new Error('[[error:email-confirmations-are-disabled]]'));
}
user.getMultipleUserFields(uids, ['uid', 'email'], function(err, usersData) {
if (err) {
return callback(err);
}
async.eachLimit(usersData, 50, function(userData, next) {
if (userData.email && userData.uid) {
user.email.verify(userData.uid, userData.email, next);
} else {
next();
}
}, callback);
});
};
User.sendPasswordResetEmail = function(socket, uids, callback) {
if (!Array.isArray(uids)) {
return callback(new Error('[[error:invalid-data]]'));

@ -27,11 +27,16 @@ var async = require('async'),
});
};
UserEmail.verify = function(uid, email) {
UserEmail.verify = function(uid, email, callback) {
callback = callback || function() {};
var confirm_code = utils.generateUUID(),
confirm_link = nconf.get('url') + '/confirm/' + confirm_code;
plugins.fireHook('filter:user.verify.code', confirm_code, function(err, confirm_code) {
if (err) {
return callback(err);
}
async.series([
function(next) {
db.setObject('confirm:' + confirm_code, {
@ -43,7 +48,9 @@ var async = require('async'),
db.expireAt('confirm:' + confirm_code, Math.floor(Date.now() / 1000 + 60 * 60 * 2), next);
}
], function(err) {
if (err) {
return callback(err);
}
user.getUserField(uid, 'username', function(err, username) {
if (err) {
return winston.error(err.stack);
@ -64,10 +71,12 @@ var async = require('async'),
if (plugins.hasListeners('action:user.verify')) {
plugins.fireHook('action:user.verify', {uid: uid, data: data});
callback();
} else if (plugins.hasListeners('action:email.send')) {
emailer.send('welcome', uid, data);
emailer.send('welcome', uid, data, callback);
} else {
winston.warn('No emailer to send verification email!');
callback();
}
});
});

@ -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="send-validation-email"><i class="fa fa-fw fa-mail-forward"></i> Send Validation 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>

Loading…
Cancel
Save