Skip to content

Commit

Permalink
Merge pull request #125 from vtex-apps/feat/remove-b2b-from-session
Browse files Browse the repository at this point in the history
New mutation to remove/add B2B session data
  • Loading branch information
Arthur Bond authored Feb 6, 2024
2 parents 09c409e + 70da66f commit 6ea3f12
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/qe-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
jobs:
quality-engineering:
name: QE
uses: vtex-apps/usqa/.github/workflows/quality-engineering.yml@v2
uses: vtex-apps/usqa/.github/workflows/quality-engineering.yml@v2.1.14
with:
cypress: true
cyRunnerBranch: ${{ github.event.inputs.cyRunnerBranch }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qe-pull-request-target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
quality-engineering:
name: QE
uses: vtex-apps/usqa/.github/workflows/quality-engineering.yml@v2
uses: vtex-apps/usqa/.github/workflows/quality-engineering.yml@v2.1.14
with:
danger: true
dangerRequireChangelog: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qe-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
quality-engineering:
name: QE
uses: vtex-apps/usqa/.github/workflows/quality-engineering.yml@v2
uses: vtex-apps/usqa/.github/workflows/quality-engineering.yml@v2.1.14
with:
danger: true
dangerRequireChangelog: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qe-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
quality-engineering:
name: QE
uses: vtex-apps/usqa/.github/workflows/quality-engineering.yml@v2
uses: vtex-apps/usqa/.github/workflows/quality-engineering.yml@v2.1.14
with:
nodeLint: true
nodeTest: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qe-schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
quality-engineering:
name: QE
uses: vtex-apps/usqa/.github/workflows/quality-engineering.yml@v2
uses: vtex-apps/usqa/.github/workflows/quality-engineering.yml@v2.1.14
with:
cypress: true
cyRunnerTimeOut: 45
Expand Down
26 changes: 13 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

- New `ignoreB2BSessionData` mutation to allow a user to leave/resume the B2B context

## [1.38.0] - 2023-12-14

### Added
Expand Down Expand Up @@ -52,16 +56,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [1.35.2] - 2023-07-13

### Changed

- Edited README.md file

## [1.35.1] - 2023-06-29

### Fixed
### Fixed

- Removing the document on orderform in case of business/corporate profile data
- Removing all the non digits from the business document to prevent checkout errors


## [1.35.0] - 2023-05-31

### Added
Expand Down Expand Up @@ -89,11 +93,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [1.33.3] - 2023-05-08

### Fixed

- Fixed issue where `documentType` is always set to cpf

## [1.33.2] - 2023-05-03

### Fixed

- geoCoordinates empty

## [1.33.1] - 2023-04-21
Expand All @@ -106,24 +112,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed

- Fix on impersonation user

- Fix on impersonation user

## [1.32.0] - 2023-04-19

### Added

- Added the x-b2b-senderapp header to fix problems with the new B2B API


## [1.31.5] - 2023-04-11

### Fixed

- Fixed clear call async calls

- Fixed clear call async calls

### Removed

- [ENGINEERS-1247] - Disable cypress tests in PR level

### Changed
Expand All @@ -137,7 +141,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed the `setProfile` to clear the cart properly
- Improved calls on set profile in order to get faster response


## [1.31.3] - 2023-03-01

### Fixed
Expand All @@ -147,6 +150,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [1.31.2] - 2023-02-27

### Fixed

- `setProfile` adding sku 1 to the cart to set sales channel when the cart is empty
- `setProfile` losing item attachments after login

Expand All @@ -162,7 +166,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Added a feature when the user logs in or changes the current organization.


## [1.30.0] - 2023-02-09

### Added
Expand Down Expand Up @@ -226,7 +229,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- getOrganizationsByEmail is returning all users instead of only first 50 records


## [1.29.2] - 2022-11-28

### Fixed
Expand All @@ -245,7 +247,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [1.29.0] - 2022-11-08


### Added

- Added the functionality to the storefront permissions to change the sales channel according to the Organization
Expand All @@ -262,7 +263,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Force the business document and state registration on setProfile method


## [1.27.0] - 2022-10-19

### Changed
Expand Down Expand Up @@ -299,7 +299,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed

- Changed the validation of the add user
- Changed the validation of the add user

### Added

Expand Down
4 changes: 4 additions & 0 deletions graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ type Mutation {
@withSession
@cacheControl(scope: PRIVATE)
@withSender

ignoreB2BSessionData(enabled: Boolean!): MutationResponse
@withSession
@cacheControl(scope: PRIVATE)
}

type UserImpersonation {
Expand Down
29 changes: 29 additions & 0 deletions node/resolvers/Mutations/Users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,3 +639,32 @@ export const setCurrentOrganization = async (
return { status: 'error', message: error }
}
}

export const ignoreB2BSessionData = async (
_: void,
{ enabled }: { enabled: boolean },
ctx: Context
) => {
const {
cookies,
request,
vtex: { logger },
clients: { session },
} = ctx

const sessionCookie =
cookies.get('vtex_session') ?? request.header?.sessiontoken

try {
await session.updateSession('removeB2B', enabled, [], sessionCookie)

return { status: 'success', message: '' }
} catch (error) {
logger.error({
error,
message: 'removeB2BSessionData.error',
})

return { status: 'error', message: error }
}
}
9 changes: 9 additions & 0 deletions node/resolvers/Routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ export const Routes = {
let stateRegistration = null
let user = null

const ignoreB2B = body?.public?.removeB2B?.value

if (ignoreB2B) {
ctx.response.body = response
ctx.response.status = 200

return
}

if (b2bImpersonate) {
try {
user = (await getUser({
Expand Down
2 changes: 2 additions & 0 deletions node/resolvers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
addOrganizationToUser,
addUser,
deleteUser,
ignoreB2BSessionData,
impersonateUser,
saveUser,
setActiveUserByOrganization,
Expand Down Expand Up @@ -40,6 +41,7 @@ export const resolvers = {
addUser,
deleteRole,
deleteUser,
ignoreB2BSessionData,
impersonateUser,
saveRole,
saveUser,
Expand Down
2 changes: 1 addition & 1 deletion node/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ sprintf-js@~1.0.2:
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=

"stats-lite@github:vtex/node-stats-lite#dist":
stats-lite@vtex/node-stats-lite#dist:
version "2.2.0"
resolved "https://codeload.github.com/vtex/node-stats-lite/tar.gz/1b0d39cc41ef7aaecfd541191f877887a2044797"
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion vtex.session/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"authentication": ["storeUserEmail"],
"checkout": ["orderFormId"],
"impersonate": ["storeUserEmail", "storeUserId"],
"public": ["impersonate"]
"public": ["impersonate", "removeB2B"]
},
"output": {
"public": ["facets", "sc", "regionId"],
Expand Down

0 comments on commit 6ea3f12

Please sign in to comment.