From 386ae6cc04d74a3d981fc4bacfe1678be491cd92 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Tue, 31 Dec 2024 18:21:31 +0600 Subject: [PATCH 1/3] fix: use correct scopes for request, approve, reject and make correction in root-resolver --- .../src/features/correction/root-resolvers.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) 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') From da1fa2f63351e6713072d6a60db602cee996e826 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Tue, 31 Dec 2024 18:25:21 +0600 Subject: [PATCH 2/3] fix: show `sentForApproval` tab for `RECORD_REGISTRATION_REQUEST_CORRECTION` scope --- packages/client/src/hooks/useNavigation.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/client/src/hooks/useNavigation.ts b/packages/client/src/hooks/useNavigation.ts index b8d2f445e1..cef1f77661 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, From b0483d011e5c105c5166d2187b08dc4491df0466 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Thu, 2 Jan 2025 12:49:38 +0600 Subject: [PATCH 3/3] fix: unit test: update scope for req correction --- packages/gateway/src/features/correction/root-resolvers.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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',