AnonymousCartMergingMiddleware not working for Azure B2C Login

Vote:
 

Good afternoon Opti people.

I'm having an issue on opti commerce (B2C) with the AnonymousCartMergingMiddleware (ported from Foundation). Basically the issue is that when I sign in with a DB user, everything is fine and the Anonymous ID is retained (both in code and in the cookie). But when signing in with an Azure B2C user, the Anonymous ID changes (both in code and cookie) and therefore the AnonymousCartMergingMiddleware fails to retrieve the cart. Is this something anyone else has experienced / fixed? Grateful for any pointers!

Best regards,

Sam

#316760
Feb 06, 2024 16:48
Vote:
 

Managed to get this working by: 

  1. Setting an authentication property for Anonymous ID on the options.Events.OnRedirectToIdentityProvider event
  2. Retrieving the Anonymous ID from the authentication property in options.Events.OnTokenValidated
  3. Writing the cookie back down, also on the options.Events.OnTokenValidated event

Once the cookie is set the middleware will actually work and grab the right cart!

#316762
Feb 06, 2024 18:24
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.