2
votes

I have a problem with FOSUserBundle and HWIOauthBundle. I use custom UserChecker to check whether user is banned (custom table in database as I need a ban history). When I use Facebook to log-in my CustomChecker is not used. It does work when I'm using login and password as authentication.

Issue on GitHub: https://github.com/hwi/HWIOAuthBundle/issues/1358

Anyone has an idea how to fix that?

2
can't you override hwi_oauth.user_checker?Denis Alimov

2 Answers

1
votes

from the docs

Services & Configuration

If you want to modify service definitions of another bundle, you can use a compiler pass to change the class of the service or to modify method calls. In the following example, the implementing class for the original-service-id is changed to App\YourService:

// src/Kernel.php
namespace App;

// ...
+ use App\Service\YourService;
+ use Symfony\Component\DependencyInjection\ContainerBuilder;
+ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

class Kernel extends BaseKernel implements CompilerPassInterface
{
+     public function process(ContainerBuilder $container)
+     {
+         $definition = $container->findDefinition('original-service-id');
+         $definition->setClass(YourService::class);
+     }
}
0
votes

I confirm, the solution of @Domagoj work for Symfony 3.4.

# app/config/services.yml
services:
...
    security.user_checker:
        class: AppBundle\Service\YourUserChecker

With this code, the hwi.user_checker is override by your UserChecker.

Thanks.