|
|
|
@ -84,35 +84,38 @@ SocketUser.reset.send = function(socket, email, callback) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SocketUser.reset.commit = function(socket, data, callback) {
|
|
|
|
|
if(data && data.code && data.password) {
|
|
|
|
|
async.series([
|
|
|
|
|
async.apply(db.getObjectField, 'reset:uid', data.code),
|
|
|
|
|
async.apply(user.reset.commit, data.code, data.password)
|
|
|
|
|
], function(err, data) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
if (!data || !data.code || !data.password) {
|
|
|
|
|
return callback(new Error('[[error:invalid-data]]'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var uid = data[0],
|
|
|
|
|
now = new Date(),
|
|
|
|
|
parsedDate = now.getFullYear() + '/' + (now.getMonth()+1) + '/' + now.getDate();
|
|
|
|
|
async.parallel({
|
|
|
|
|
uid: async.apply(db.getObjectField, 'reset:uid', data.code),
|
|
|
|
|
reset: async.apply(user.reset.commit, data.code, data.password)
|
|
|
|
|
}, function(err, results) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
user.getUserField(uid, 'username', function(err, username) {
|
|
|
|
|
emailer.send('reset_notify', uid, {
|
|
|
|
|
username: username,
|
|
|
|
|
date: parsedDate,
|
|
|
|
|
site_title: meta.config.title || 'NodeBB',
|
|
|
|
|
subject: '[[email:reset.notify.subject]]'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
events.log({
|
|
|
|
|
type: 'password-reset',
|
|
|
|
|
uid: socket.uid,
|
|
|
|
|
ip: socket.ip
|
|
|
|
|
var uid = results.uid,
|
|
|
|
|
now = new Date(),
|
|
|
|
|
parsedDate = now.getFullYear() + '/' + (now.getMonth()+1) + '/' + now.getDate();
|
|
|
|
|
|
|
|
|
|
user.getUserField(uid, 'username', function(err, username) {
|
|
|
|
|
emailer.send('reset_notify', uid, {
|
|
|
|
|
username: username,
|
|
|
|
|
date: parsedDate,
|
|
|
|
|
site_title: meta.config.title || 'NodeBB',
|
|
|
|
|
subject: '[[email:reset.notify.subject]]'
|
|
|
|
|
});
|
|
|
|
|
callback();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
events.log({
|
|
|
|
|
type: 'password-reset',
|
|
|
|
|
uid: uid,
|
|
|
|
|
ip: socket.ip
|
|
|
|
|
});
|
|
|
|
|
callback();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SocketUser.checkStatus = function(socket, uid, callback) {
|
|
|
|
|