Skip to content

Commit

Permalink
#1258 addressing comments from team
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-flores committed Aug 19, 2024
1 parent 278065c commit 0efc8aa
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion api-docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,7 @@
"Organization"
],
"summary": "Updates information about the organization specified by short name (accessible to Secretariat)",
"description": " <h2>Access Control</h2> <p>User must belong to an organization with the <b>Secretariat</b> role</p> <h2>Expected Behavior</h2> <p><b>CNA:</b> Updates 'last_active' timestamp to show that a CNA is still active</p> <p><b>Secretariat:</b> Updates any organization's information</p>",
"description": " <h2>Access Control</h2> <p>User must belong to an organization with the <b>Secretariat</b> or <b>CNA</b> role</p> <h2>Expected Behavior</h2> <p><b>CNA:</b> Updates 'last_active' timestamp to show that a CNA is still active</p> <p><b>Secretariat:</b> Updates any organization's information</p>",
"operationId": "orgUpdateSingle",
"parameters": [
{
Expand Down
46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/controller/org.controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,10 @@ router.put('/org/:shortname',
}
*/
mw.validateUser,
param(['shortname']).isString().trim().isLength({ min: CONSTANTS.MIN_SHORTNAME_LENGTH, max: CONSTANTS.MAX_SHORTNAME_LENGTH }),
mw.validateOrg,
query().custom((query) => { return mw.validateQueryParameterNames(query, ['new_short_name', 'id_quota', 'name', 'active_roles.add', 'active_roles.remove']) }),
query(['new_short_name', 'id_quota', 'name', 'active_roles.add', 'active_roles.remove']).custom((val) => { return mw.containsNoInvalidCharacters(val) }),
param(['shortname']).isString().trim().isLength({ min: CONSTANTS.MIN_SHORTNAME_LENGTH, max: CONSTANTS.MAX_SHORTNAME_LENGTH }),
query(['new_short_name']).optional().isString().trim().notEmpty().isLength({ min: CONSTANTS.MIN_SHORTNAME_LENGTH, max: CONSTANTS.MAX_SHORTNAME_LENGTH }),
query(['id_quota']).optional().not().isArray().isInt({ min: CONSTANTS.MONGOOSE_VALIDATION.Org_policies_id_quota_min, max: CONSTANTS.MONGOOSE_VALIDATION.Org_policies_id_quota_max }).withMessage(errorMsgs.ID_QUOTA),
query(['name']).optional().isString().trim().notEmpty(),
Expand Down
6 changes: 4 additions & 2 deletions src/controller/org.controller/org.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,9 @@ async function updateOrg (req, res, next) {
newOrg.last_active = Date.now()
}
})
} else {
}

if (shortName === orgMakingChanges) {
newOrg.last_active = Date.now()
}

Expand Down Expand Up @@ -414,7 +416,7 @@ async function updateOrg (req, res, next) {
result = result.length > 0 ? result[0] : null

if (!isSec) {
if (!result.last_active) {
if (!result || !result.last_active) {
return res.status(500).json(error.serverError())
}
result = { last_active: result.last_active }
Expand Down

0 comments on commit 0efc8aa

Please sign in to comment.