注销处理程序Silex

问题描述 投票:0回答:1

我想在注销后更改USER的状态。但我不知道如何制作它。

$app->register(new Silex\Provider\SecurityServiceProvider());
$app['security.firewalls'] = array(
        'chat' => array(
            'pattern'=>'/chat',
            'anonymous'=>false,
            //login_path: before authorisation  Check_path: path to check the date of the user
            'form'=>array('login_path'=>'/login','check_path' => '/chat/login_check'),
            //should realizise the logout
            'logout'=>array('logout_path'=>'/chat/logout','target_url'=>'/logout'),
            'users'=> $app->share(function() use ($app){
                return new \resources\controller\UserProvider($app['db']);
            })
        )
);

似乎没有会议了。我已经和了

'invalidate_session'=>false 

'invalidate_session'=>true 

选项。它不工作。

谢谢您帮忙

security service logout silex provider
1个回答
1
投票

您可以添加注销处理程序

$app->extend('security.firewall', function($firewall, $app) {
    static $initialized = false;
    if ($initialized) return $firewall;
    $initialized = true;

    // logout handlers
    $app['security.authentication_listener.administration.logout']->addHandler(
        new \My\Logout\LogoutHandler()
    );

    return $firewall;
});

LogoutHandler应该实现LogoutHandlerInterface

class LogoutHandler implements LogoutHandlerInterface
{
    public function logout(Request $request, Response $response, TokenInterface $token)
    {
        $user = $token->getUser();
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.