Is there an easy way to get a credential/permission for a particular user?
I’ve seen the hasCredential() method, but I’d like to dynamically check any user, not just the current user.
I know I can use sfContext::getInstance()->getUser(); to get the current user object, but is there a way to load in any user and get his/her credentials?
Thanks
It kind of depends on the “store” you’re using. In Symfony the current user (the one provided with
sfContext::getInstance()->getUser()) is more an abstraction of the session.So the most used plugin for authentication, sfDoctrineGuard, has controllers (sfGuardAuth) which handle things like a a signin form, and once succesful, it will populate the
sfUseraccordingly.So, if you want to check for the permissions of a user, you will have to check the underlying store. If you’re using
sfDoctrineGuard, you can retrieve a User model throughsfGuardUserTable::getInstance()->find(...). On thesfGuardUser, you can call thehasPermission($name)function to check.