Skip to content

Commit

Permalink
token encoding and decoding fixed (vercel#19)
Browse files Browse the repository at this point in the history
Co-authored-by: Chandradeepta <43542673+Chandradeepta@users.noreply.github.com>
  • Loading branch information
kibo-chandradeeptalaha and Chandradeepta committed Sep 15, 2021
1 parent 5b58fcf commit e6a5d61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions framework/kibocommerce/api/endpoints/cart/remove-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ const removeItem: CartEndpoint['handlers']['removeItem'] = async ({
errors: [{ message: 'Invalid request' }],
})
}
const token = req.cookies[config.customerCookie]
const encodedToken = req.cookies[config.customerCookie]
const token = encodedToken
? Buffer.from(encodedToken, 'base64').toString('ascii')
: null

let accessToken = token ? JSON.parse(token).accessToken : null
const accessToken = token ? JSON.parse(token).accessToken : null

const removeItemResponse = await config.fetch(
removeItemFromCartMutation,
Expand Down
7 changes: 5 additions & 2 deletions framework/kibocommerce/api/endpoints/cart/update-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ const updateItem: CartEndpoint['handlers']['updateItem'] = async ({
errors: [{ message: 'Invalid request' }],
})
}
const token = req.cookies[config.customerCookie]
const encodedToken = req.cookies[config.customerCookie]
const token = encodedToken
? Buffer.from(encodedToken, 'base64').toString('ascii')
: null

let accessToken = token ? JSON.parse(token).accessToken : null
const accessToken = token ? JSON.parse(token).accessToken : null

const updateItemResponse = await config.fetch(
updateCartItemQuantityMutation,
Expand Down

0 comments on commit e6a5d61

Please sign in to comment.