Skip to content

Commit 8ad2566

Browse files
authored
Merge pull request #1509 from CVEProject/dr_1496_userValidationMiddleware_fixes
Resolves #1496 - user validation middleware fixes
2 parents 27a1cad + b097f52 commit 8ad2566

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/middleware/middleware.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,7 @@ async function validateUser (req, res, next) {
133133
return res.status(401).json(error.unauthorized())
134134
}
135135

136-
const activeInOrg = true
137-
138-
if ((!useRegistry && !result.active) ||
139-
(useRegistry && !activeInOrg)) {
136+
if (result.active === false || result.status === 'inactive') {
140137
logger.warn(JSON.stringify({ uuid: req.ctx.uuid, message: 'User deactivated. Authentication failed for ' + user }))
141138
return res.status(401).json(error.unauthorized())
142139
}

src/repositories/baseUserRepository.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ class BaseUserRepository extends BaseRepository {
189189
legacyObjectRaw.secret = secret
190190

191191
// Registry Only Fields
192+
registryObjectRaw.status = 'active'
192193
// Legacy Specific fields
194+
legacyObjectRaw.active = true
193195

194196
// Get UUID of org, that is having the user added to it.
195197
const existingOrg = await baseOrgRepository.findOneByShortName(orgShortName)

test/unit-tests/middleware/validateUserTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class NullUserRepo {
7070
}
7171
}
7272

73-
describe.skip('Testing the user validation middleware', () => {
73+
describe('Testing the user validation middleware', () => {
7474
context('Negative Tests', () => {
7575
it('Org does not exist', (done) => {
7676
app.route('/validate-user-org-doesnt-exist')

0 commit comments

Comments
 (0)