Skip to content

Commit

Permalink
Merge pull request #110 from vtex-apps/fix/impersonation2
Browse files Browse the repository at this point in the history
Fix/impersonation2
  • Loading branch information
arturmagalhaesjr authored Apr 21, 2023
2 parents 14b80ad + 73712b0 commit ff43b42
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 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]

### Fixed

- Fixed impersonation user

## [1.24.1] - 2023-04-13

### Fixed
Expand Down
10 changes: 5 additions & 5 deletions react/components/OrganizationUsersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ADD_USER from '../graphql/addUser.graphql'
import UPDATE_USER from '../graphql/updateUser.graphql'
import REMOVE_USER from '../graphql/removeUser.graphql'
import GET_COST_CENTER from '../graphql/getCostCenterStorefront.graphql'
import IMPERSONATE_USER from '../graphql/impersonateUser.graphql'
import IMPERSONATE_USER from '../graphql/impersonateB2BUser.graphql'
import { B2B_CHECKOUT_SESSION_KEY } from '../utils/constants'

interface Props {
Expand Down Expand Up @@ -361,16 +361,16 @@ const OrganizationUsersTable: FunctionComponent<Props> = ({
}

impersonateUser({
variables: { clId: rowData.clId, userId: rowData.userId },
variables: { id: rowData.id },
})
.then(result => {
if (result?.data?.impersonateUser?.status === 'error') {
if (result?.data?.impersonateB2BUser?.status === 'error') {
console.error(
'Impersonation error:',
result.data.impersonateUser.message
result.data.impersonateB2BUser.message
)
if (
result.data.impersonateUser.message === 'userId not found in CL'
result.data.impersonateB2BUser.message === 'userId not found in CL'
) {
showToast(formatMessage(storeMessages.toastImpersonateIdMissing))
} else {
Expand Down
8 changes: 8 additions & 0 deletions react/graphql/impersonateB2BUser.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mutation ImpersonateB2BUser($id: ID!) {
impersonateB2BUser(id: $id)
@context(provider: "vtex.b2b-organizations-graphql") {
id
status
message
}
}

0 comments on commit ff43b42

Please sign in to comment.