This commit is contained in:
Andris Reinman 2017-06-12 12:51:44 +03:00
parent 03f9d650bf
commit a8eb98a870
3 changed files with 33 additions and 2 deletions

View file

@ -314,6 +314,37 @@ class UserHandler {
});
}
reset(username, callback) {
let password = generatePassword.generate({
length: 12,
uppercase: true,
numbers: true,
symbols: false
});
return this.database.collection('users').findOneAndUpdate({
username
}, {
$set: {
enabled2fa: false,
seed: '',
requirePasswordChange: true,
password: bcrypt.hashSync(password, 11)
}
}, {}, (err, result) => {
if (err) {
log.error('DB', 'UPDATEFAIL username=%s error=%s', username, err.message);
return callback(new Error('Database Error, failed to reset user credentials'));
}
if (!result || !result.value) {
return callback(new Error('Could not update user'));
}
return callback(null, password);
});
}
setup2fa(username, issuer, callback) {
return this.database.collection('users').findOne({
username

2
package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "wildduck",
"version": "1.0.50",
"version": "1.0.51",
"lockfileVersion": 1,
"dependencies": {
"@ronomon/crypto-async": {

View file

@ -1,6 +1,6 @@
{
"name": "wildduck",
"version": "1.0.51",
"version": "1.0.52",
"description": "IMAP server built with Node.js and MongoDB",
"main": "server.js",
"scripts": {