Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,20 @@ async function getAllOrgs (req, res, next) {
async function getOrg (req, res, next) {
try {
const repo = req.ctx.repositories.getRegistryOrgRepository()
// User passed in parameter to filter for
const identifier = req.ctx.params.identifier
const orgShortName = req.ctx.org
const isSecretariat = await repo.isSecretariat(orgShortName)
const org = await repo.findOneByShortName(orgShortName)
let orgIdentifer = orgShortName
let agt = setAggregateOrgObj({ UUID: identifier })
let requestingUserOrgIdentifier = orgShortName
let agt = setAggregateOrgObj({ short_name: identifier })

if (validateUUID(identifier)) {
orgIdentifer = org.UUID
requestingUserOrgIdentifier = org.UUID
agt = setAggregateOrgObj({ UUID: identifier })
}

if (orgIdentifer !== identifier && !isSecretariat) {
if (requestingUserOrgIdentifier !== identifier && !isSecretariat) {
logger.info({ uuid: req.ctx.uuid, message: identifier + ' organization can only be viewed by the users of the same organization or the Secretariat.' })
return res.status(403).json(error.notSameOrgOrSecretariat())
}
Expand Down
Loading