fix error handling

This commit is contained in:
Ben Irvin 2023-05-24 09:40:04 +02:00
parent de6537791e
commit 9404cb352e

View File

@ -9,7 +9,8 @@ const sso = require('./passport/sso');
const { isSsoLocked } = require('../utils/sso-lock');
const localStrategyMiddleware = async ([error, user, message], done) => {
if (await isSsoLocked(user)) {
// if we got a user, we need to check that it's not sso locked
if (user && !error && (await isSsoLocked(user))) {
throw new UnauthorizedError('Login not allowed, please contact your administrator', {
code: 'LOGIN_NOT_ALLOWED',
});