From 694d661f7e98e2553e48d7641659593cad9d013f Mon Sep 17 00:00:00 2001 From: Jamil Date: Thu, 2 Jan 2025 14:35:35 +0600 Subject: [PATCH] fix: Scopes: correction related scopes (#8268) * fix: use correct scopes for request, approve, reject and make correction in root-resolver * fix: show `sentForApproval` tab for `RECORD_REGISTRATION_REQUEST_CORRECTION` scope * fix: unit test: update scope for req correction --- packages/client/src/hooks/useNavigation.ts | 5 ++++- .../correction/root-resolvers.test.ts | 2 +- .../src/features/correction/root-resolvers.ts | 19 ++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/client/src/hooks/useNavigation.ts b/packages/client/src/hooks/useNavigation.ts index 5cff1d3612..7da6ce9f50 100644 --- a/packages/client/src/hooks/useNavigation.ts +++ b/packages/client/src/hooks/useNavigation.ts @@ -56,7 +56,10 @@ const routeAccess: NavigationConfig[] = [ }, { name: WORKQUEUE_TABS.sentForApproval, - scopes: [SCOPES.RECORD_SUBMIT_FOR_APPROVAL] + scopes: [ + SCOPES.RECORD_SUBMIT_FOR_APPROVAL, + SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION + ] }, { name: WORKQUEUE_TABS.requiresUpdate, diff --git a/packages/gateway/src/features/correction/root-resolvers.test.ts b/packages/gateway/src/features/correction/root-resolvers.test.ts index 64c83acc38..efd89730ef 100644 --- a/packages/gateway/src/features/correction/root-resolvers.test.ts +++ b/packages/gateway/src/features/correction/root-resolvers.test.ts @@ -24,7 +24,7 @@ describe('Correction root resolvers', () => { beforeEach(() => { registerCertifyToken = jwt.sign( - { scope: ['record.register'] }, + { scope: ['record.registration-request-correction'] }, readFileSync('./test/cert.key'), { subject: '121223', diff --git a/packages/gateway/src/features/correction/root-resolvers.ts b/packages/gateway/src/features/correction/root-resolvers.ts index 0287e2373a..e7555e8d8b 100644 --- a/packages/gateway/src/features/correction/root-resolvers.ts +++ b/packages/gateway/src/features/correction/root-resolvers.ts @@ -41,10 +41,7 @@ export const resolvers: GQLResolver = { { headers: authHeader } ) { if ( - inScope(authHeader, [ - SCOPES.RECORD_REGISTER, - SCOPES.RECORD_SUBMIT_FOR_APPROVAL - ]) + inScope(authHeader, [SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION]) ) { const hasAssignedToThisUser = await checkUserAssignment(id, authHeader) if (!hasAssignedToThisUser) { @@ -62,7 +59,7 @@ export const resolvers: GQLResolver = { { id, details }, { headers: authHeader } ) { - if (inScope(authHeader, [SCOPES.RECORD_REGISTER])) { + if (inScope(authHeader, [SCOPES.RECORD_REGISTRATION_CORRECT])) { const hasAssignedToThisUser = await checkUserAssignment(id, authHeader) if (!hasAssignedToThisUser) { throw new UnassignError('User has been unassigned') @@ -78,7 +75,7 @@ export const resolvers: GQLResolver = { { id, details }, { headers: authHeader } ) { - if (inScope(authHeader, [SCOPES.RECORD_REGISTER])) { + if (inScope(authHeader, [SCOPES.RECORD_REGISTRATION_CORRECT])) { const hasAssignedToThisUser = await checkUserAssignment(id, authHeader) if (!hasAssignedToThisUser) { throw new UnassignError('User has been unassigned') @@ -98,7 +95,7 @@ export const resolvers: GQLResolver = { { id, details }, { headers: authHeader } ) { - if (inScope(authHeader, [SCOPES.RECORD_REGISTER])) { + if (inScope(authHeader, [SCOPES.RECORD_REGISTRATION_CORRECT])) { const hasAssignedToThisUser = await checkUserAssignment(id, authHeader) if (!hasAssignedToThisUser) { throw new UnassignError('User has been unassigned') @@ -118,7 +115,7 @@ export const resolvers: GQLResolver = { { id, details }, { headers: authHeader } ) { - if (inScope(authHeader, [SCOPES.RECORD_REGISTER])) { + if (inScope(authHeader, [SCOPES.RECORD_REGISTRATION_CORRECT])) { const hasAssignedToThisUser = await checkUserAssignment(id, authHeader) if (!hasAssignedToThisUser) { throw new UnassignError('User has been unassigned') @@ -138,7 +135,7 @@ export const resolvers: GQLResolver = { { id, details }, { headers: authHeader } ) { - if (inScope(authHeader, [SCOPES.RECORD_REGISTER])) { + if (inScope(authHeader, [SCOPES.RECORD_REGISTRATION_CORRECT])) { const hasAssignedToThisUser = await checkUserAssignment(id, authHeader) if (!hasAssignedToThisUser) { throw new UnassignError('User has been unassigned') @@ -158,7 +155,7 @@ export const resolvers: GQLResolver = { { id, details }, { headers: authHeader } ) { - if (inScope(authHeader, [SCOPES.RECORD_REGISTER])) { + if (inScope(authHeader, [SCOPES.RECORD_REGISTRATION_CORRECT])) { const hasAssignedToThisUser = await checkUserAssignment(id, authHeader) if (!hasAssignedToThisUser) { throw new UnassignError('User has been unassigned') @@ -178,7 +175,7 @@ export const resolvers: GQLResolver = { { id, details }, { headers: authHeader } ) { - if (inScope(authHeader, [SCOPES.RECORD_REGISTER])) { + if (inScope(authHeader, [SCOPES.RECORD_REGISTRATION_CORRECT])) { const hasAssignedToThisUser = await checkUserAssignment(id, authHeader) if (!hasAssignedToThisUser) { throw new UnassignError('User has been unassigned')