Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Active cart is not reloaded upon changing the language when the authorization code flow is used #19269

Open
relsayed8205 opened this issue Sep 22, 2024 · 0 comments

Comments

@relsayed8205
Copy link

relsayed8205 commented Sep 22, 2024

Description
Active cart is not reloaded upon changing the language when the authorization code flow is used (keycloak integration)

Version

  • Library version: [22.11.19.0]
  • Integrated with keycloak latest version by having a new AuthConfig

ConfigModule.withConfig(<AuthConfig>{ authentication: { client_id: eto client_secret: '', loginUrl: 'auth', tokenEndpoint: 'token', userinfoEndpoint: 'userinfo', revokeEndpoint: 'revoke', logoutUrl: 'logout', baseUrl: 'http://localhost:8080/realms/eto/protocol/openid-connect', OAuthLibConfig: { responseType: 'code', scope: 'openid', postLogoutRedirectUri: 'https://localhost:4200', redirectUri: 'https://localhost:4200', issuer: 'http://localhost:8080/realms/eto', disablePKCE: false, strictDiscoveryDocumentValidation: true, skipIssuerCheck: false, } } }),

To Reproduce
Steps to reproduce the behavior:

  1. Call the shop, it is an open shop.
  2. Click login, it redirects to keycloak login page and returns to the shop home page after success
  3. The user has an active cart e.g. 3 items
  4. Logout, and login again
  5. On the home page, change the language using the standard language selector

The mini cart show 0 items. Open the cart page, it is empty. Active cart is not loaded.

Expected behavior
The mini cart show 3 items.

The language selector causes the following snippet to be called in the ActiveCartService
const loading = cartValue$.pipe( withLatestFrom(this.activeCartId$, this.userIdService.getUserId()), tap(([{ cart, loaded, isStable }, cartId, userId]) => { if ( isStable && isEmpty(cart) && !loaded && !isTempCartId(cartId) && this.shouldLoadCartOnCodeFlow ) { this.load(cartId, userId); } }) );
When the problem happens the shouldLoadCartOnCodeFlow value is false. It is set to false in the detectUserChange() method
if (this.isLoggedInWithCodeFlow()) { // only when code flow // Prevent loading cart while merging. this.shouldLoadCartOnCodeFlow = false; .... // call loadOrMerge }

So what happens is:
After login the detectUserChange is called setting the boolean to false, but it loads the cart. Changing the language will not reload the cart as shouldLoadCartOnCodeFlow remains false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant