ClankBundle icon indicating copy to clipboard operation
ClankBundle copied to clipboard

Security.context issue in RPCs

Open Merk87 opened this issue 10 years ago • 3 comments

Hi.

I'm working around with the RPCs, and when I try to inject the security context and recover the current user, this is null

I've tried in a bunch of different ways, but I'm always back to the same point... someone was able to do this? Any idea?

Thanks.

Merk87 avatar Sep 26 '14 14:09 Merk87

Hi there! I have solved it by getting the session info, unserializing and getting the user:

private function getCurrentUser(Connection $connection) {
    $securityMain = $connection->Session->get('_security_main');

    if($securityMain) {
        $securityMain = unserialize($securityMain);
        $user = $securityMain->getUser();

        return $user;
    }

    return null;
}

Hope it helps ;)

NaxYo avatar Oct 06 '14 17:10 NaxYo

Wow that could do the trick!

Thanks!

Merk87 avatar Oct 06 '14 17:10 Merk87

@NaxYo thank you very much!

theodorDiaconu avatar Jul 21 '15 08:07 theodorDiaconu