Skip to content

Commit

Permalink
fix: Scopes: correction related scopes (#8268)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jamil314 authored Jan 2, 2025
1 parent ad687d0 commit 694d661
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
5 changes: 4 additions & 1 deletion packages/client/src/hooks/useNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
19 changes: 8 additions & 11 deletions packages/gateway/src/features/correction/root-resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand Down

0 comments on commit 694d661

Please sign in to comment.