diff --git a/lib/user-handler.js b/lib/user-handler.js index 1826b973..fddedb7e 100644 --- a/lib/user-handler.js +++ b/lib/user-handler.js @@ -40,7 +40,6 @@ class UserHandler { * @param {String} username Either username or email address */ authenticate(username, password, callback) { - let checkAddress = next => { if (username.indexOf('@') < 0) { // assume regular username @@ -62,16 +61,22 @@ class UserHandler { if (err) { return callback(err); } + if (!addressData) { return callback(null, false); } + return next(null, { _id: addressData.user }); }); }; - checkAddress(query => { + checkAddress((err, query) => { + if (err) { + return callback(err); + } + this.database.collection('users').findOne(query, { fields: { username: true, @@ -80,7 +85,6 @@ class UserHandler { asp: true } }, (err, userData) => { - if (err) { return callback(err); } @@ -113,7 +117,7 @@ class UserHandler { user: userData._id, username: userData.username, scope: 'application', - use2fa: false + enabled2fa: false // application scope never requires 2FA }); } } diff --git a/package.json b/package.json index e19272bd..0c917a63 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wildduck", - "version": "1.0.18", + "version": "1.0.19", "description": "IMAP server built with Node.js and MongoDB", "main": "server.js", "scripts": {