Search code examples
symfony1sfguard

How to force login with sfGuard?


Does anyone have any of how to force a login action with sfGuard through code? Something like: $this->authenticate('username'); ?

Thanks in advance.


Solution

  • I think it was:

    $user = // sfGuardUser object
    $user_id = $user->getId();
    
    $this->getUser()->signIn($user_id, true);
    

    ... with the second parameter being true/false for "remember me".

    See the signIn function in the sfGuardSecurityUser.class.php inside the Plugin lib/user/ to see how it works.