Authentication & Orders

FrontWing implements a persistent shopping cart powered by Sylius Order Tokens and stored in browser cookies.

Customer Authentication

Users can register, log in, and manage their account using API calls to the Sylius backend.

Key endpoints:

  • POST /api/v2/shop/customers – Register

  • POST /api/v2/shop/customers/token – Login

  • GET /api/v2/shop/customers/me – Get current user

Authenticated sessions are handled via JWT tokens, stored in the frontend and sent with each request using the Authorization: Bearer <token> header.

Login and token handling is implemented in the /account/... routes and authentication context.


Order & Cart Managment

FrontWing implements a persistent shopping cart powered by Sylius Order Tokens and stored in browser cookies.

OrderContext

A custom React context (OrderContext) handles:

  • Generating an order token if missing

  • Saving it in cookies

  • Sending the token with all cart-related API requests

  • Syncing the local cart state with Sylius


How the order token works

  • On first visit, a new token is created and stored in cookies

  • On page reloads or future visits, the token is reused

  • All cart operations (add/remove/update) use this token

  • After completing checkout, the token is reset

Relevant API endpoints:

  • GET /api/v2/shop/orders/{tokenValue} – Fetch current order

  • POST /api/v2/shop/orders/{tokenValue}/items – Add item to cart

  • DELETE /api/v2/shop/orders/{tokenValue}/items/{itemId} – Remove item

  • PUT /api/v2/shop/orders/{tokenValue}/items/{itemId} – Update quantity

Debugging cart/session issues

If the cart isn't updating or returns 422 errors:

  • Check that the order token is sent correctly in requests

  • Ensure the Sylius backend allows cookies (CORS, domain)

  • Confirm the token is reset after checkout to avoid stale orders

Last updated

Was this helpful?