I think I have found a better solution. The sfDoctrineGuard plugin has its own message validator that checks for an optional user being called.
all:
sf_guard_plugin:
retrieve_by_username_callable: sfGuardUser::getForBackend
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();
}
source
share