Open simahawk opened 8 months ago
@lmignon gentle ping :)
@simahawk I'm back from holidays, I'll try to get back to you later this week.
Hi @simahawk,
If you look at the demo app (#1364), there is a _get_cart_app_dependencies_overrides
function that is used to set the right authentication mechanism (i.e. auth_jwt_authenticated_or_anonymous_partner_autocreate
) on the cart routes.
That mechanisms either authenticates a known partner, or creates an anonymous partner and sets a cookie to identify it (see the shopinvader_anonymous_partner
addon).
In v14 we had a single partner shared by all anonymous carts. With the new API, we create a new anonymous partner for each visitor that populates the cart: it should be simpler in the end, for instance when different anonymous partners are from different countries or such.
The last missing part is the conversion of the anonymous partner into a known partner (and transfer of the cart) upon signin. @qgroulard is working on it these days. The plan for that is in https://github.com/shopinvader/odoo-shopinvader/issues/1428#issuecomment-1843325040.
See also https://github.com/shopinvader/odoo-shopinvader/issues/1368 for the whole authentication story.
@sbidoul thanks for the summary and the pointers! I'll have a look :)
@simahawk Please have a look at https://github.com/shopinvader/odoo-shopinvader/pull/1523. You'll see what we have done for the jwt authentication. The management of the anonymous partner and cookie and the transfer of the carts are done in dedicated modules, hence similar logic can easily be implemented for other authentication mechanisms.
In v14 you could create a cart for an anonymous user by using
backend.anonymous_partner_id
. The cart would then be swapped the real customer upon login.What's the plan for v16?
CC @lmignon