views:

83

answers:

2

In a situation, where the user is authenticated on another application (like oAuth or a custom security implementation), how can we simulate login?

What we intend to achieve is: - use the user identifier key to check if the user exists - if the user exists, set-up the session for the user - basically, setup the attribute holder - assign the user object, so that it is available thru getUser() method So we are looking at signing-in programatically!

Any light on how do it in the simplest way?

A: 

i think its here: although u wont find working code http://stackoverflow.com/questions/2757192/symfony-login-to-application-with-get-post-token

Prasad
+1  A: 

if using sfDoctrineGuardPlugin, i'd do something like:

  1. Redirect user to 3rd part oAuth provider
  2. On success, user returns to you, either create them a new sfGuardUser object, or retrieve the appropriate one (you may need to adapt the schema to have somewhere to store extra oAuth data).
  3. Call myUser()->signIn($user), where $user in the previously retrieved sfGuardUser object - eg: I use this in register actions to log people in after registration: $this->getUser()->signin($user);
benlumley
cool.. can't wait to try this! i hope the signin method is implemented in the base class! will let you know.. thanks a ton!
Prasad