1
votes

I have a Symfony 4 website with users and login process. I'd like to add a new Entity "customer" and allow to the customer to log in using the same process as User.

When I try to edit the security.yaml file, I have this error : Not configuring explicitly the provider for the "guard" listener on "main" firewall is ambiguous as there is more than one registered provider.

My encoders are declared :

encoders:
        App\Entity\User:
            algorithm: bcrypt
        App\Entity\Client:
            algorithm: bcrypt

My providers as well : providers:

app_user_provider:
    entity:
        class: App\Entity\User
        property: email
        manager_name: user
app_customer_provider:
    entity:
        class: App\Entity\Customer
        property: email
        manager_name: customer

And the main firewall :

main:
            logout:
                path: app_logout
            anonymous: true
            guard:
                authenticators:
                    - App\Security\LoginFormAuthenticator

I tried different way to declare the new firewall but it doesn't work. Is it possible to use the same Security process for two providers ? Am I missing something ?

Thanks

1

1 Answers

6
votes

you should add provider to your firewall since you have more than one provider symfony does not know which one do your want to use so try config you firewall like this

 main:
  logout:
      path: app_logout
  anonymous: true
  provider: app_user_provider
  guard:
     authenticators:
           - App\Security\LoginFormAuthenticator

don't forget to cache:clear you can find it in their document here