Skip to content

Commit

Permalink
fix: provide correct tokens to clients (#135)
Browse files Browse the repository at this point in the history
* fix: provide correct tokens to clients

* fix: changelog
  • Loading branch information
enzomerca authored Apr 24, 2024
1 parent 155b2ad commit 533a16e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed
- Provide correct auth tokens to clients

## [1.40.2] - 2024-04-19

### Fixed
Expand Down
15 changes: 10 additions & 5 deletions node/clients/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ import { Schema } from './schema'
import VtexId from './vtexId'

export const getTokenToHeader = (ctx: IOContext) => {
const token =
ctx.storeUserAuthToken ?? ctx.adminUserAuthToken ?? ctx.authToken
const adminToken = ctx.adminUserAuthToken ?? ctx.authToken
const userToken = ctx.storeUserAuthToken ?? null
const { sessionToken, account } = ctx

const { sessionToken } = ctx
let allCookies = `VtexIdclientAutCookie=${adminToken}`

if (userToken) {
allCookies += `; VtexIdclientAutCookie_${account}=${userToken}`
}

return {
VtexIdclientAutCookie: token,
cookie: `VtexIdclientAutCookie=${token}`,
VtexIdclientAutCookie: adminToken,
cookie: allCookies,
'x-vtex-session': sessionToken ?? '',
}
}
Expand Down

0 comments on commit 533a16e

Please sign in to comment.