Lexik JWT and API Platform : logical explanations needed, please

I’m trying to learn how to create RESTful APis and modern(er) frontends, using Symfony with API Platform in backend, and Vue with vue-router in front (so no routes configured in Symfony controllers).

I installed and configured Lexik JWT Bundle (with Gesdinet refresh bundle), set on HttpOnly Cookie, and it works: when I test a get request for something via api/docs, it refuses as expected if I don’t login first. Nice.

But what I don’t understand is…what now ?

For example, I just want to get the connected user profile, so make a (get) call to "api/users/{id}" but how can I do that ? How do I get the user ID from the token (stored in cookie) ? Is it even possible through Vue (and should it ?)? Or how to configure Symfony and Api Platform to decode the payload automatically and give the correct response (accept or not, considering the role user or admin, and the requested id)?

There’s someting in the Lexik JWT and API Platform flow that I just don’t understand yet.
Could someone help me ?

Thank you

Bonus question : how to logout ?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *