Symfony2 custom user checker based on accepted eula

前端 未结 3 1905
余生分开走
余生分开走 2020-12-20 15:59

I want to create custom user checker to validate login action against last accepted eula. \' Idea is quite simple, there will be many versions of eula and user can\'

3条回答
  •  旧巷少年郎
    2020-12-20 16:06

    Why not attach event listener to the kernel.request event and watch if the current logged user has accepted the latest EULA?

    To get the current user you can use something like this:

    $securityContext = $this->container->get('security.context');
    if (!$securityContext) {
        return;
    }
    
    $user = $securityContext->getToken()->getUser();
    

提交回复
热议问题