Using Aimeos Authentication with an External React Frontend

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
Jairus34
Posts: 20
Joined: 05 Aug 2024, 07:34

Using Aimeos Authentication with an External React Frontend

Post by Jairus34 » 06 Oct 2024, 09:51

Hi everyone,

I’m working on a project using Aimeos for the backend and React for the front end, and I’d like to integrate Aimeos’s authentication features (login, logout, and customer registration) into my external React app.

From what I understand, the Aimeos Laravel package uses Laravel Breeze for authentication. How can I access and use these authentication routes in my React frontend? Are there any specific configurations or steps I must follow to make this work smoothly?

Environment:

OS: macOS
Aimeos version: 2024.07.1
Aimeos Laravel package: https://github.com/aimeos/aimeos-laravel

Any guidance or examples would be greatly appreciated!

Thanks in advance.

User avatar
aimeos
Administrator
Posts: 8262
Joined: 01 Jan 1970, 00:00

Re: Using Aimeos Authentication with an External React Frontend

Post by aimeos » 07 Oct 2024, 13:04

Laravel Breeze isn't suitable for a PWA as it provides no API. In the Aimeos headless distribution, we use JWT:
https://github.com/aimeos/aimeos-headle ... n-rest-api

We suggest to use the Aimeos headless distribution instead. If you can't because you want to integrate Aimeos into an existing application, you need to add JWT yourself. You can check the headless distribution as a working example.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
Jairus34
Posts: 20
Joined: 05 Aug 2024, 07:34

Re: Using Aimeos Authentication with an External React Frontend

Post by Jairus34 » 09 Oct 2024, 15:22

Hi, thanks for your reply!

I’ve successfully integrated the registration route from the auth route into the API route using Aimeos Headless. The registration works, but I noticed that when a customer is registered through the API, the siteid in the customer table is set to null. However, when I create a customer through the Aimeos admin, the siteid is set to 1. The same behavior also occurs when using the register route from the auth route.

Is the siteid required for the customer? Should I manually retrieve and assign the siteid when registering customers through the API?

User avatar
aimeos
Administrator
Posts: 8262
Joined: 01 Jan 1970, 00:00

Re: Using Aimeos Authentication with an External React Frontend

Post by aimeos » 10 Oct 2024, 07:35

The site ID is important if you have several sites (e.g. in a SaaS setup) and accounts need to be bound to a specific site (e.g. the vendor accounts). Customers with an empty site ID will be available and have access to all sites but only super users can change their data in the admin backend.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
Jairus34
Posts: 20
Joined: 05 Aug 2024, 07:34

Re: Using Aimeos Authentication with an External React Frontend

Post by Jairus34 » 11 Oct 2024, 02:52

Hello aimeos,

In my case, we only have one site. So I guess we don't need the siteId for the customers.

User avatar
Jairus34
Posts: 20
Joined: 05 Aug 2024, 07:34

Re: Using Aimeos Authentication with an External React Frontend

Post by Jairus34 » 11 Oct 2024, 06:50

Hi everyone,

I have a question about creating a customer using the registration route in the API. I've noticed that when I register a customer, the siteId is not being set, and as a result, the customer cannot be updated in the Aimeos Admin. Is there a specific reason for this behavior?

Thanks in advance for your help!
Attachments
Screenshot 2024-10-11 at 2.50.13 PM.png
Screenshot 2024-10-11 at 2.50.13 PM.png (186.7 KiB) Viewed 6313 times
Screenshot 2024-10-11 at 2.46.46 PM.png
Screenshot 2024-10-11 at 2.46.46 PM.png (57.57 KiB) Viewed 6313 times

User avatar
aimeos
Administrator
Posts: 8262
Joined: 01 Jan 1970, 00:00

Re: Using Aimeos Authentication with an External React Frontend

Post by aimeos » 11 Oct 2024, 07:24

Like said, only super users can do that for security reasons if the customer record has no site ID set
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply