Hey guys! We are trying to use glue storefront api with customer session access but we are struggling with \Spryker\Glue\GlueStorefrontApiApplication\Application\GlueStorefrontApiApplication::setUpSession
It looks like there is some workaround implemented to use \Spryker\Glue\GlueApplication\Session\Storage\MockArraySessionStorage.
Please compare:
Also the setUpSession method looks like a forgotten workaround because it is not using Spryker conventions to use factory methods to instantiate classes.
/** * @return void */ protected function setUpSession(): void { (new SessionClient())->setContainer( new Session( new MockArraySessionStorage(), ), ); }
Can anyone please explain how this is supposed to be used and adjusted?
@spryker
Let me rephrase the question.
In the old Glue there is the possibility to define getControllerBeforeActionPlugins
in the GlueApplicationDependencyProvider.
A SetCustomerBeforeActionPlugin
is used here to set the customer in the session from the RestRequestTransfer.
How is this intended for the storefront api? Can someone explain this?
Sorry for being not fast as you might've expected.
I provide here explanation, how I'd implement similar logic.
Adding a plugin into \Spryker\Glue\GlueApplication\GlueApplicationDependencyProvider::getRequestBuilderPlugins let's you enrich the GlueRequest with any details about the request, including details about logged in user/customer.
Session usage is discouraged, since it's kept for a backward compatibility reasons, and as every global resource is a code-smell for a session-less API request processing.
Hey Andrey! No worries, that was really fast enough ;)
Thank you for your explanation! I will try it that way!
Heyhey @DavidGreiner ,
We are trying to use glue storefront api with customer session access
I also want to emphase on the point that Glue (Storefront|Backend) API is a RESTful API and therefore should not be tied to any session! I would avoid it as much as I could!
What I normally suggest for a hybrid-solution with Yves (and what i implemented in a project partly already):
When you login through Yves, generate the access-token for glue in the background and provide it (through html?) to the frontend. There is just one case you need to cover additionally: The token can expire and you need to catch this somehow and renew it.
Hope this helps somehow.
All the best,
Florian