Adds a new field last_active to the Org schema, and updates this field to Date.now() when PUT /org/{shortname} is hit. Only a secretariat can use this endpoint to make changes to fields other than last_active.
Important Changes
src/controller/org.controller/index.js
Replaced mw.onlySecretariat with mw.validateOrg -- all Orgs can now call this endpoint, but only secretariats can use this endpoint to make changes to fields other than last_active
src/controller/org.controller/org.controller.js
Added functionality to update the last_active field, and only allow secretariats to make other changes.
src/middleware/middleware.js
new function validateOrg checks to see if either 1) the requester is the secretariat, or 2) the requester is trying to make changes to their own org. If one of these cases is true, continue with the request. Otherwise, return 403 forbidden.
src/model/org.js
added last_active field to org schema
test/integration-tests/org/putOrgTest.js
Added 5 integration tests for updated endpoint functionality
Testing
Steps to manually test updated functionality
[ npm run test:integration] 1) Run integration test suite
[ npm run test:unit-tests] 1) Run unit test suite
Notes
time.modified field also updates when endpoint is called
Closes Issue #1258
Summary
Adds a new field
last_active
to the Org schema, and updates this field toDate.now()
when PUT /org/{shortname} is hit. Only a secretariat can use this endpoint to make changes to fields other thanlast_active
.Important Changes
src/controller/org.controller/index.js
mw.onlySecretariat
withmw.validateOrg
-- all Orgs can now call this endpoint, but only secretariats can use this endpoint to make changes to fields other thanlast_active
src/controller/org.controller/org.controller.js
last_active
field, and only allow secretariats to make other changes.src/middleware/middleware.js
validateOrg
checks to see if either 1) the requester is the secretariat, or 2) the requester is trying to make changes to their own org. If one of these cases is true, continue with the request. Otherwise, return 403 forbidden.src/model/org.js
last_active
field to org schematest/integration-tests/org/putOrgTest.js
Testing
Steps to manually test updated functionality
npm run test:integration
] 1) Run integration test suitenpm run test:unit-tests
] 1) Run unit test suiteNotes
time.modified
field also updates when endpoint is called