Skip to content

Commit

Permalink
fix: Set optional authentication for get picks by list id
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Szuchet committed Jun 15, 2023
1 parent 474371b commit c0f6e53
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 38 deletions.
10 changes: 0 additions & 10 deletions src/controllers/handlers/lists-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ export async function getPicksByListIdHandler(
} = context
const userAddress: string | undefined = verification?.auth.toLowerCase()

if (!userAddress) {
return {
status: StatusCode.UNAUTHORIZED,
body: {
ok: false,
message: 'Unauthorized'
}
}
}

const { limit, offset } = getPaginationParams(url.searchParams)
const picksByListIdResult = await lists.getPicksByListId(params.id, {
userAddress,
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function setupRouter({ components: { schemaValidator } }: GlobalContext):
router.get(
'/v1/lists/:id/picks',
authorizationMiddleware.wellKnownComponents({
optional: false,
optional: true,
expiration: FIVE_MINUTES
}),
getPicksByListIdHandler
Expand Down
5 changes: 3 additions & 2 deletions src/ports/lists/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ export interface IListsComponents {
}

export type GetAuthenticatedAndPaginatedParameters = {
userAddress: string
userAddress?: string
} & PaginationParameters

export type GetListsParameters = GetAuthenticatedAndPaginatedParameters & {
export type GetListsParameters = PaginationParameters & {
userAddress: string
sortBy?: ListSortBy
sortDirection?: ListSortDirection
itemId?: string | null
Expand Down
25 changes: 0 additions & 25 deletions test/unit/lists-handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,6 @@ describe('when getting the picks of a list', () => {
params = { id: listId }
})

describe('and the request is not authenticated', () => {
beforeEach(() => {
verification = undefined
})

it('should return an unauthorized response', () => {
return expect(
getPicksByListIdHandler({
url,
components,
verification,
request,
params
})
).resolves.toEqual({
status: StatusCode.UNAUTHORIZED,
body: {
ok: false,
message: 'Unauthorized',
data: undefined
}
})
})
})

describe('and the process to get the picks fails', () => {
let error: Error

Expand Down

0 comments on commit c0f6e53

Please sign in to comment.