- Code: Select all
//app.yml
all:
sf_guard_plugin:
retrieve_by_username_callable: sfGuardUser::getForBackend
//sfGuardUser.class.php
public static function getForBackend($username)
{
$query = Doctrine::getTable('sfGuardUser')->createQuery('u')
->leftJoin('u.Groups g')
->leftJoin('g.Permissions p')
->where('u.username = ? OR u.email_address = ?', array($username, $username))
->addWhere('u.is_active = ?', true)
->addWhere('p.name = ?', 'backend');
return $query->fetchOne();
}
Works fine, except that user has only one credential now ('backend'), but should have more.
Here are the fixtures:
- Code: Select all
sfGuardGroup:
Group_admin:
name: admin
Permissions: [Permission_admin, Permission_chief, Permission_expert, Permission_backend]
sfGuardPermission:
Permission_admin:
name: admin
Permission_chief:
name: chief
Permission_expert:
name: expert
Permission_backend:
name: backend
So, user should have all permissions of 'admin' group, but only gets 'backend' permission. Looks like a bug, isn't it?
P.S. If I remove the last line from query (->addWhere('p.name = ?', 'backend')) then credentials are set correctly.
