# config/packages/security.yaml
security:
    password_hashers:
        App\Entity\User: 'auto'

    providers:
        app_user_provider:
            entity:
                class: App\Entity\User
                property: email

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        
        # Firewall principal
        main:
            pattern: ^/
            stateless: false
            provider: app_user_provider
            # Utilisez le bon nom de votre authenticator
            custom_authenticator: App\Security\LoginFormAuthenticator
            logout:
                path: app_logout
                target: home
            remember_me:
                secret: '%kernel.secret%'
                lifetime: 604800
                path: /
                always_remember_me: true

    # ⚠️ IMPORTANT: La configuration access_control doit être au bon niveau
    access_control:
        # Routes publiques
        - { path: ^/$, roles: PUBLIC_ACCESS }
        - { path: ^/login$, roles: PUBLIC_ACCESS }
        - { path: ^/register$, roles: PUBLIC_ACCESS }
        - { path: ^/products, roles: PUBLIC_ACCESS }
        - { path: ^/product/, roles: PUBLIC_ACCESS }
        - { path: ^/category, roles: PUBLIC_ACCESS }
        - { path: ^/vendor/\d+$, roles: PUBLIC_ACCESS }
        
        # ⚠️ Routes protégées - SANS le entry_point qui cause l'erreur
        - { path: ^/cart, roles: ROLE_USER }
        - { path: ^/checkout, roles: ROLE_USER }
        - { path: ^/account, roles: ROLE_USER }
        - { path: ^/vendor/dashboard, roles: ROLE_VENDOR }
        - { path: ^/vendor/register, roles: ROLE_USER }
        - { path: ^/api/cart, roles: ROLE_USER }
        - { path: ^/api/orders, roles: ROLE_USER }
        - { path: ^/admin, roles: ROLE_ADMIN }

when@test:
    security:
        password_hashers:
            Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
                algorithm: auto
                cost: 4
                time_cost: 3
                memory_cost: 10