2
votes

The route of FosUserBundle '/login' must not be accessible in Production mode. It must redirect to the route '/choiceConnexion'.

I thought I had this working because in dev mode there is a redirect successfully taking place, using 'config/routes/dev/routes.yaml' in this mode. However when setting the env in prod, the redirect doesn't work.

I have tried putting similar confingurations in a config/routes/prod folder, thinking it would switch, however it doesn't work.

I assumed in Prod the first code snippet below woulc be called:

config/routes.yaml

home_choiceConnexion:
  path: /login
  controller: App\Controller\HomeController::choiceConnexion

The above doesn't work, however in dev, the rerouting taking place in config/dev/routes.yaml does work when the app is in dev mode.

fos_user_security_login:
  path: /softia/login
  controller: FOS\UserBundle\Controller\SecurityController::loginAction

The main difference is that '/login' already exists, so I think the rerouting doesn't get prioretized and doesn't override the route fos_user_security_login.

I need to achieve this redirection for a client's project and would be grateful of any help.

1
possibly the order of routes is wrong? iirc, symfony uses last route it finds defined, also try to check debug:router for list of routes in your projectLudo
I checked in prod mode and the debug:router shows what it's supposed to: home_choiceConnexion ANY ANY ANY /login fos_user_security_login ANY ANY ANY /softia/loginaPurpleDev
However in prod mode, when I enter the route '/login' I can see that it's still taking me to the FOSUser default '/login'.. thank you for the helpaPurpleDev
Can you run APP_ENV=prod php bin/console router:match /login and see if the expected route is being used?dbrumann
Have you checked if HomeController::choiceConnexion does an accidental redirect to the other route at some point?dbrumann

1 Answers

0
votes

Update: I have delivered a git branched which seem to work, I simply used annotation on the controller to this effect and it seems there's no conflict with the '/login' from the fosUserBundle.

Will update the post if this doesn't solve it.

/**
     * @Route("/choiceConnexion", name="home_choiceConnexion")
     * @Route("/login")
     */