chok / sfMelodyPlugin

Allow to communicate with many services(google, yahoo...) throw OAuth
MIT License
45 stars 21 forks source link

Import Facebook friends on login #27

Closed tobiassjosten closed 13 years ago

tobiassjosten commented 13 years ago

The title explains what I want to achieve. When a user logs in, be it for the first or 32th time, I want to update her friends from Facebook. The problem I'm having is that the first time she logs in I don't yet have an access token.

I have tried overriding the signin() method in myUser and also triggering on the user.change_authentication event. Neither works because the token does not yet exist.

My current plan is to keep triggering on that event and update my Facebook friends if I have a token. Then I would also trigger on the postInsert() method for my Token model, to fetch the first time my user logs in.

Only I just can't help but thinking there must be a cleaner way to solve this?

chok commented 13 years ago

I maybe misunderstood but why you don't make that in the callback of facebook authentification ?

tobiassjosten commented 13 years ago

I never thought of that... My callback is currently @homepage but I could just make it a import-facebook-friends action that redirects to @homepage when it's finished. Should work.

Thanks!

tobiassjosten commented 13 years ago

I created a new action, put all the calls to my logic there and the had t redirect back to @homepage. Worked like a charm – cheers. :)

chok commented 13 years ago

:)