Skip to content

Commit d7e8477

Browse files
Merge pull request #62 from eosdis-nasa/hotfix-approve-privilage-fix
Fix privilege check for approval
2 parents b7fc524 + bcf3b55 commit d7e8477

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/nodejs/lambda-handlers/submission.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ async function submitMethod(event, user) {
148148
}
149149

150150
async function reviewMethod(event, user) {
151-
const approvedUserRoles = ['ADMIN', 'REQUEST_REVIEW', 'REQUEST_REVIEW_MANAGER'];
151+
const approvedUserPrivileges = ['ADMIN', 'REQUEST_REVIEW', 'REQUEST_REVIEW_MANAGER'];
152152
const { id, approve } = event;
153153
const status = await db.submission.getState({ id });
154-
if (user.user_roles.some((role) => approvedUserRoles.includes(role.short_name))) {
154+
if (user.user_privileges.some((privilege) => approvedUserPrivileges.includes(privilege))) {
155155
const stepType = status.step.type;
156156
let eventType;
157157
if (approve === 'false' || !approve) {

src/nodejs/lambda-handlers/test/handlers/submission.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ describe('submission', () => {
177177
id: 'test id',
178178
approve: true
179179
};
180-
db.user.findById.mockReturnValue({ id: 'test user', user_roles: [{ short_name: 'REQUEST_REVIEW' }] });
180+
db.user.findById.mockReturnValue({ id: 'test user', user_privileges: ['REQUEST_REVIEW'] });
181181
db.submission.getState.mockReturnValue({
182182
conversation_id: 'test conversation',
183183
workflow_id: 'test workflow',

0 commit comments

Comments
 (0)