-2

After I login my Sylius app (site login, not admin login), I am redirected to /shop (It is the path to the SyliusShopBundle, defined in my app/config/routing.yml) Is it possible to override the login redirection to be redirected to / (where I have put static index page)?

Thanks !

EDIT : here is my code after the answer of CoderMaggie

sylius_shop_login:
    path: /shop/login
    methods: [GET]
    defaults:
        _controller: sylius.controller.security:loginAction
        _sylius:
            template: "@SyliusShop/login.html.twig"
            redirect:
                route: homepage

but I am not redirected to route homepage

wyllyjon
  • 425
  • 5
  • 18

1 Answers1

3

I'm not sure why you are redirected to the /shop it's not the default behaviour. There is no such route even.

But if you are customizing things this will be the approach :)

sylius_shop_login:
    path: /login
    methods: [GET]
    defaults:
        _controller: sylius.controller.security:loginAction
        _sylius:
            template: "@SyliusShop/login.html.twig"
            redirect:
                route: your_route_here_if_other_than_the_original_one
CoderMaggie
  • 228
  • 2
  • 8
  • Tks CoderMaggie. I am redirected to /shop because it is the route I have declared to go to the SyliusBundle. But after login, I would like to go to the root of my website, which is not the shop. I try your solution – wyllyjon Jan 16 '17 at 15:32
  • I try adding this code to my app/config/routes.yml, after all the routes for Sylius. But I am still redirected to /shop after my login. Any idea why ? The symfony doc about overriding routes is not very clear : https://symfony.com/doc/current/bundles/override.html#routing – wyllyjon Jan 16 '17 at 15:38
  • The route seems to be overriden, because if I change loginAction to loginAction2, I have an error. But the redirection to "homepage" does not work. – wyllyjon Jan 16 '17 at 15:48
  • 1
    CoderMaggie, I was reading the Security doc of Symfony, and saw there is a `default_target_path` in the `firewall.shop.form_login`. I have changed the value from `sylius_shop_homepage` to `homepage` and it worked. Is this a good way to do it ? – wyllyjon Jan 18 '17 at 08:28
  • 1
    Yes. :D That was the place the the redirect was still present ;) – CoderMaggie Jan 18 '17 at 11:47