fix: added variables to the constants file.
fix: updated sql queries with constants
This commit is contained in:
parent
3c2cbac23f
commit
aa7252dfce
5 changed files with 35 additions and 16 deletions
|
|
@ -1,6 +1,8 @@
|
|||
const otplib = require('otplib')
|
||||
const argon2 = require('argon2')
|
||||
|
||||
const constants = require('../../../constants')
|
||||
const authTokens = require('../../../auth-tokens')
|
||||
const loginHelper = require('../../services/login')
|
||||
const T = require('../../../time')
|
||||
const users = require('../../../users')
|
||||
|
|
@ -76,7 +78,7 @@ const get2FASecret = (username, password) => {
|
|||
return authenticateUser(username, password)
|
||||
.then(user => {
|
||||
const secret = otplib.authenticator.generateSecret()
|
||||
const otpauth = otplib.authenticator.keyuri(user.username, 'Lamassu', secret)
|
||||
const otpauth = otplib.authenticator.keyuri(user.username, constants.AUTHENTICATOR_ISSUER_ENTITY, secret)
|
||||
return Promise.all([users.saveTemp2FASecret(user.id, secret), secret, otpauth])
|
||||
})
|
||||
.then(([_, secret, otpauth]) => {
|
||||
|
|
@ -125,7 +127,7 @@ const validateReset2FALink = token => {
|
|||
})
|
||||
.then(user => {
|
||||
const secret = otplib.authenticator.generateSecret()
|
||||
const otpauth = otplib.authenticator.keyuri(user.username, 'Lamassu', secret)
|
||||
const otpauth = otplib.authenticator.keyuri(user.username, constants.AUTHENTICATOR_ISSUER_ENTITY, secret)
|
||||
return Promise.all([users.saveTemp2FASecret(user.id, secret), user, secret, otpauth])
|
||||
})
|
||||
.then(([_, user, secret, otpauth]) => {
|
||||
|
|
@ -185,12 +187,12 @@ const disableUser = (code, id, context) => {
|
|||
}
|
||||
|
||||
const createResetPasswordToken = (code, userID, context) => {
|
||||
const action = () => users.createAuthToken(userID, 'reset_password')
|
||||
const action = () => authTokens.createAuthToken(userID, 'reset_password')
|
||||
return executeProtectedAction(code, userID, context, action)
|
||||
}
|
||||
|
||||
const createReset2FAToken = (code, userID, context) => {
|
||||
const action = () => users.createAuthToken(userID, 'reset_twofa')
|
||||
const action = () => authTokens.createAuthToken(userID, 'reset_twofa')
|
||||
return executeProtectedAction(code, userID, context, action)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue