php - symfony login using database, no database queries performed -


i have made login, repository custom databasequery , it's working otherwise there no database queries made. using symfony 3

in firewall under providers:

providers:     in_memory:         memory: ~     database:         entity:           class: appbundle:customer           property: customer_email encoders:     symfony\component\security\core\user\user:       algorithm: bcrypt       cost: 20  firewalls:     # disables authentication assets , profiler, adapt according needs     dev:         pattern: ^/(_(profiler|wdt)|css|images|js)/         security: false     login_firewall:         pattern: ^/login$         anonymous: ~     main:         pattern: ^/         # activate different ways authenticate         provider: database          form_login:             login_path: /login             check_path: /login_check             csrf_token_generator: security.csrf.token_manager             target_path_parameter: /dashboard             always_use_default_target_path: true          # http_basic: ~         # http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate          # form_login: ~         # http://symfony.com/doc/current/cookbook/security/form_login_setup.html          logout:             path: /logout access_control:      - { path: ^/login, roles: is_authenticated_anonymously }  role_hierarchy:     role_admin: [role_user] 

repository query:

<?php        # src/appbundle/entity/customerrepository.php       namespace appbundle\entity;        use symfony\bridge\doctrine\security\user\userloaderinterface;       use symfony\component\security\core\user\userinterface;       use symfony\component\security\core\exception\usernamenotfoundexception;       use doctrine\orm\entityrepository;        class customerrepository extends entityrepository implements userloaderinterface       {         public function loaduserbyusername($email)         {           $user = $this->createquerybuilder('c')             ->where('c.customer_email = :email')             ->setparameter('email', $email)             ->getquery()             ->getoneornullresult();              if(null === $user)             {               $message = sprintf(                 'unable find active user appbundle:user object identified "%s".',                 $email               );               throw new usernamenotfoundexception($message);               print_r('eac');             }              return $user;         }       } 

however, still debugger says no queries performed, throw error invalid login details thought.

if check symfony docs on multiple firewalls, see following:

if you're using multiple firewalls , authenticate against 1 firewall, not authenticated against other firewalls automatically. different firewalls different security systems. have explicitly specify same firewall context different firewalls. applications, having 1 main firewall enough.

what happening, in login_firewall , trying login main, should never work.

what helped me this:

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

see difference? removed whole login_firewall section , added anonymous: ~ main firewall section.

now, if configure access_control section right, anything, /login, should not accessible anonymously:

access_control:     - { path: ^/login, roles: is_authenticated_anonymously }     - { path: ^/, roles: role_user } 

Comments