Skip to content

Commit ceef005

Browse files
authored
Merge branch 'dev' into emathew/1400-registryOrg-createUserByOrg
2 parents dd4fff5 + 2488b5f commit ceef005

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/controller/registry-org.controller/registry-org.controller.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,14 @@ async function createOrg (req, res, next) {
9494
const registryOrgRepo = req.ctx.repositories.getRegistryOrgRepository()
9595
const body = req.ctx.body
9696

97+
// Short circuit if UUID provided
98+
const bodyKeys = Object.keys(body).map(k => k.toLowerCase())
99+
if (bodyKeys.includes('uuid')) {
100+
return res.status(400).json(error.uuidProvided('org'))
101+
}
102+
97103
const newOrg = new RegistryOrg()
98-
Object.keys(body).map(k => k.toLowerCase()).forEach(k => {
104+
bodyKeys.forEach(k => {
99105
if (k === 'long_name') {
100106
newOrg.long_name = body[k]
101107
} else if (k === 'short_name') {
@@ -138,8 +144,6 @@ async function createOrg (req, res, next) {
138144
website: '',
139145
...contactInfo
140146
}
141-
} else if (k === 'uuid') {
142-
return res.status(400).json(error.uuidProvided('org'))
143147
}
144148
})
145149

src/controller/registry-user.controller/registry-user.controller.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ async function createUser (req, res, next) {
7171
const registryUserRepo = req.ctx.repositories.getRegistryUserRepository()
7272
const body = req.ctx.body
7373

74+
// Short circuit if UUID provided
75+
const bodyKeys = Object.keys(body).map((k) => k.toLowerCase())
76+
if (bodyKeys.includes('uuid')) {
77+
return res.status(400).json(error.uuidProvided('user'))
78+
}
79+
7480
// TODO: check if affiliated orgs and program orgs exist, and if their membership limit is reached
7581

7682
const newUser = new RegistryUser()
@@ -89,8 +95,6 @@ async function createUser (req, res, next) {
8995
// TODO: dedupe
9096
} else if (k === 'cve_program_org_membership') {
9197
// TODO: dedupe
92-
} else if (k === 'uuid') {
93-
return res.status(400).json(error.uuidProvided('user'))
9498
}
9599
})
96100

0 commit comments

Comments
 (0)