Use authInfo obj vs weird params. auth factor 1: factor 2 for 2FA, etc.

This commit is contained in:
Bryan Ashby
2019-02-22 22:51:12 -07:00
parent 57938e761e
commit 23779c3abe
4 changed files with 27 additions and 16 deletions

View File

@@ -15,6 +15,7 @@ const {
const UserProps = require('./user_property.js');
const SysProps = require('./system_property.js');
const SystemLogKeys = require('./system_log.js');
const User = require('./user.js');
// deps
const async = require('async');
@@ -39,7 +40,15 @@ function userLogin(client, username, password, options, cb) {
}, 2000);
}
client.user.authenticate(username, password, options, err => {
const authInfo = {
username,
password,
};
authInfo.type = options.authType || User.AuthFactor1Types.Password;
authInfo.pubKey = options.ctx;
client.user.authenticateFactor1(authInfo, err => {
if(err) {
client.user.sessionFailedLoginAttempts = _.get(client.user, 'sessionFailedLoginAttempts', 0) + 1;
const disconnect = config.users.failedLogin.disconnect;