Skip to content

Commit

Permalink
fix: amend data seeding user scope (#8323)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nil20 authored Jan 13, 2025
1 parent 39a3530 commit c946959
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions packages/events/src/router/middleware/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ const createScopeAuthMiddleware =
throw new TRPCError({ code: 'UNAUTHORIZED' })

Check failure on line 55 in packages/events/src/router/middleware/middleware.ts

View workflow job for this annotation

GitHub Actions / Test (packages/events)

src/router/locations.get.test.ts > Returns single location in right format

TRPCError: UNAUTHORIZED ❯ src/router/middleware/middleware.ts:55:11 ❯ callRecursive ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:143:30 ❯ procedure ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:176:30 ❯ ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/router.mjs:124:34 ❯ Object.apply ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/createProxy.mjs:46:20 ❯ src/router/locations.get.test.ts:29:45 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'UNAUTHORIZED' }

Check failure on line 55 in packages/events/src/router/middleware/middleware.ts

View workflow job for this annotation

GitHub Actions / Test (packages/events)

src/router/locations.get.test.ts > Returns multiple locations

TRPCError: UNAUTHORIZED ❯ src/router/middleware/middleware.ts:55:11 ❯ callRecursive ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:143:30 ❯ procedure ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:176:30 ❯ ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/router.mjs:124:34 ❯ Object.apply ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/createProxy.mjs:46:20 ❯ src/router/locations.get.test.ts:38:45 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'UNAUTHORIZED' }

Check failure on line 55 in packages/events/src/router/middleware/middleware.ts

View workflow job for this annotation

GitHub Actions / Test (packages/events)

src/router/locations.set.test.ts > Creates single location

TRPCError: UNAUTHORIZED ❯ src/router/middleware/middleware.ts:55:11 ❯ callRecursive ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:143:30 ❯ procedure ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:176:30 ❯ ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/router.mjs:124:34 ❯ Object.apply ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/createProxy.mjs:46:20 ❯ src/router/locations.set.test.ts:44:45 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'UNAUTHORIZED' }

Check failure on line 55 in packages/events/src/router/middleware/middleware.ts

View workflow job for this annotation

GitHub Actions / Test (packages/events)

src/router/locations.set.test.ts > Creates multiple locations

TRPCError: UNAUTHORIZED ❯ src/router/middleware/middleware.ts:55:11 ❯ callRecursive ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:143:30 ❯ procedure ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:176:30 ❯ ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/router.mjs:124:34 ❯ Object.apply ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/createProxy.mjs:46:20 ❯ src/router/locations.set.test.ts:62:45 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'UNAUTHORIZED' }

Check failure on line 55 in packages/events/src/router/middleware/middleware.ts

View workflow job for this annotation

GitHub Actions / Test (packages/events)

src/router/locations.set.test.ts > Removes existing locations not in payload

TRPCError: UNAUTHORIZED ❯ src/router/middleware/middleware.ts:55:11 ❯ callRecursive ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:143:30 ❯ procedure ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs:176:30 ❯ ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/router.mjs:124:34 ❯ Object.apply ../../node_modules/@trpc/server/dist/unstable-core-do-not-import/createProxy.mjs:46:20 ❯ src/router/locations.set.test.ts:72:45 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'UNAUTHORIZED' }
}

const isNationalSystemAdminUser = createScopeAuthMiddleware([
SCOPES.CONFIG_UPDATE_ALL
])
const isDataSeedingUser = createScopeAuthMiddleware([SCOPES.USER_DATA_SEEDING])

export const middleware = {
isNationalSystemAdminUser
isDataSeedingUser
}
2 changes: 1 addition & 1 deletion packages/events/src/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export const appRouter = router({
}),
locations: router({
set: publicProcedure
.use(middleware.isNationalSystemAdminUser)
.use(middleware.isDataSeedingUser)
.input(z.array(Location).min(1))
.mutation(async (options) => {
await setLocations(options.input)
Expand Down

0 comments on commit c946959

Please sign in to comment.