fix: login with disabled used

This commit is contained in:
Sérgio Salgado 2021-04-16 19:40:05 +01:00 committed by Josh Harvey
parent 9d028897bd
commit 6eaebc3108

View file

@ -1,6 +1,5 @@
const otplib = require('otplib')
const bcrypt = require('bcrypt')
const { AuthenticationError } = require('apollo-server-express')
const loginHelper = require('../../services/login')
const T = require('../../../time')
@ -14,7 +13,7 @@ function authenticateUser(username, password) {
return users.getUserByUsername(username)
.then(user => {
const hashedPassword = user.password
if (!hashedPassword) throw new authErrors.InvalidCredentialsError()
if (!hashedPassword || !user.enabled) throw new authErrors.InvalidCredentialsError()
return Promise.all([bcrypt.compare(password, hashedPassword), hashedPassword])
})
.then(([isMatch, hashedPassword]) => {