0

So here's the thing, I created a symfony 4 app with 2 roles: ROLE_USER and ROLE_Admin with 2 pages: user page and Admin page. I'm totally new to symfony and the docs aren't helping. Now I want the login screen to direct each user to his respective page. I'm using the default security.yml and It's directing to the default home page. here's my security.yaml file:

security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
    hamda:
        entity:
            class: App\Entity\User
            property: username

encoders:
    App\Entity\User: bcrypt

firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    main:
        anonymous: true
        provider: hamda
        form_login:
            login_path: login
            check_path: login
            default_target_path: /home


# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
    - { path: ^/admin, roles: ROLE_ADMIN }
Hyperion
  • 198
  • 1
  • 3
  • 18
  • Possible duplicate of [How to redirect to different url based on roles in symfony 2](https://stackoverflow.com/questions/11506155/how-to-redirect-to-different-url-based-on-roles-in-symfony-2) – habibun Mar 03 '19 at 11:51
  • That was made for Symfony 2 and 3, would it still work ? – Hyperion Mar 03 '19 at 12:01
  • ah the third comment worked. But I hope there's more practical method. – Hyperion Mar 03 '19 at 12:09
  • Does this answer your question? [Symfony redirect after login with condition on user](https://stackoverflow.com/questions/41440417/symfony-redirect-after-login-with-condition-on-user) – Elikill58 May 04 '23 at 14:10

0 Answers0