I found a way to do it, here's the code
sfContext::createInstance($this->configuration);
$this->logSection('user', 'logging user in');
$user = sfContext::getInstance()->getUser();
$user->setAttribute('user_id', '1', 'sfGuardSecurityUser');
$user->setAuthenticated(true);
$user->clearCredentials();
$user->addCredentials($user->getAllPermissionNames());
$user->setAttribute('workingClient', $options['workingClient']);
$this->logSection('user', 'User has been logged in');
Now when you call sfContext::getInstance()->getUser()->getId() it does
not break, that code will "signin" a user, seems to work but maybe
someone has a better solution?
-f1g
On May 28, 2:08 pm, Eno <[email protected]> wrote:
> On Fri, 28 May 2010, f1gm3nt wrote:
> > I'm writing a symfony task that needs a user to run some of the
> > functions. Is it possible to inject user information so that when I
> > call sfContext::getInstance()->getUser()->getId() it will not break?
>
> I could be wrong, but I dont think you have a user when you're running PHP
> on the command-line since there's no server and hence no session.
>
> --
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en