I'm finishing developing a API rest with common endpoints using FOSUserBundle, FOSResBundle and FOSoAuthBundle.
In a parallel way, I'm developing another symfony app to consume the services but I'm having several doubts about how to register and login users via API endpoints. My idea is to have 2 controllers refered it's routes (such as /login and /register) and do this actions via api endpoint.
with FOSUserbundle this actions are simple but don't know how to 'consume' trough APIRest service.
I know it's only half an answer but I currently do this with login, but not registration (I don't need it).
I am using Symfony 4 and flex, but it should work on 3.4 I think. I am also using json.
Bundles
Bundles I use for this (on top of fosuser etc):
Config
Fos Rest
Fos User
JMS Serializer
Lexik JWT
You need you generate tokens and put their location in your
.envfile. More info and a guide here.Security
Routes
Controller
I made a loginController that is really just a placeholder to override the route
Testing it
You can fire a POST request to
/loginand it should return a token!Registration
I haven't actually done this but I have a simple enough idea...
Open a route to registration in your security.yaml
Register the route
Write the controller method