Skip to content

Commit

Permalink
chore: add certify scope check in query
Browse files Browse the repository at this point in the history
  • Loading branch information
Nil20 committed Oct 21, 2024
1 parent aceb971 commit 94b35f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/commons/src/scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const scopes = [
'record.export-records',
'record.print-issue-certified-copies',
'record.bulk-print-certified-copies',
'record.certify',

// correct
'record.registration-request-correction',
Expand Down
6 changes: 3 additions & 3 deletions packages/gateway/src/features/registration/root-resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ export const resolvers: GQLResolver = {
}
},
async markBirthAsCertified(_, { id, details }, { headers: authHeader }) {
if (!hasScope(authHeader, 'record.print-issue-certified-copies')) {
if (!hasScope(authHeader, 'record.certify')) {
return Promise.reject(new Error('User does not have enough scope'))
}
return markEventAsCertified(id, details, authHeader, EVENT_TYPE.BIRTH)
Expand All @@ -503,7 +503,7 @@ export const resolvers: GQLResolver = {
return markEventAsIssued(id, details, authHeader, EVENT_TYPE.BIRTH)
},
async markDeathAsCertified(_, { id, details }, { headers: authHeader }) {
if (!hasScope(authHeader, 'record.print-issue-certified-copies')) {
if (!hasScope(authHeader, 'record.certify')) {
return Promise.reject(new Error('User does not have enough scope'))
}
return markEventAsCertified(id, details, authHeader, EVENT_TYPE.DEATH)
Expand All @@ -515,7 +515,7 @@ export const resolvers: GQLResolver = {
return markEventAsIssued(id, details, authHeader, EVENT_TYPE.DEATH)
},
async markMarriageAsCertified(_, { id, details }, { headers: authHeader }) {
if (!hasScope(authHeader, 'record.print-issue-certified-copies')) {
if (!hasScope(authHeader, 'record.certify')) {
return Promise.reject(new Error('User does not have enough scope'))
}
return markEventAsCertified(id, details, authHeader, EVENT_TYPE.MARRIAGE)
Expand Down

0 comments on commit 94b35f3

Please sign in to comment.