开发者

Symfony sfGuardSecurityUser->removeCredential not working

开发者 https://www.devze.com 2023-01-22 20:10 出处:网络
I\'m using symfony 1.4.8 and I have some code that basically looks like this (in a Filter): $user = $this->getContext()->getUser();

I'm using symfony 1.4.8 and I have some code that basically looks like this (in a Filter):

$user = $this->getContext()->getUser();
if ($condition)
    $user->addCredential('cr开发者_如何学编程ed');
else
    $user->removeCredential('cred');
die($user->hasCredential('cred');

No matter what I have done, it always registers that it has the cred credential. The die always outputs 1. I've even removed the if/else and just ran removeCredential() but it still dies with 1. Also of interest is that this is the ONLY place where this credential might be added (or removed), so I don't understand how I ALWAYS have it. I'm using sfDoctrineGuardUser plugin.

The following code is puzzling:

$user->removeCredential('cred');
var_dump($user->hasCredential('cred')); // bool(true)

also this:

var_dump($user->getCredentials()); // array(0) { }
var_dump($user->hasCredential('cred')); // bool(true)

I've also tried clearCredentials() with no luck. How can I remove this credential? I'm completely at a loss here.


Is your user a Super Admin? In such case hasCredential() always returns true.

0

精彩评论

暂无评论...
验证码 换一张
取 消