jamesedmonston / graphql-authentication

GraphQL authentication for your headless Craft CMS applications.
Other
28 stars 22 forks source link

Craft::$app->getUser()->getIdentity() return null even if the user is login. #143

Closed jesuismaxime closed 3 months ago

jesuismaxime commented 10 months ago

Once the user is logged through the GQL mutation, I need to validate that a User exist into a custom PHP Module. Even tho the mutation is successful (JSON response), the Craft's native Craft::$app->getUser()->getIdentity() return null.

Notes:

jesuismaxime commented 9 months ago

Any follow up?

jamesedmonston commented 3 months ago

You should be able to do something like the following:

$tokenService = GraphqlAuthentication::$tokenService;
$jwt = $tokenService->parseToken('the_token');
$user = $tokenService->getUserFromToken($jwt);