• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Facebook and Standard Codeigniter Login

Here's the deal:
I have my CI 2 application that has its user table with pretty much standard data:
fb_uid (Facebook User ID)
fb_username (Facebook user name i.e. http://facebook.com/username)

As you can see, a user can login with the standard login form (email/password) or connecting with Facebook.

My problem is that,
1) If a user has got a standard account on the site and the next time he logins with Facebook, I need to complete his information adding
to his row in the user table.

2) If a user arrives to the site for the first time and logins with Facebook, I need to add his Facebook information to the table and take him to a page that allows him to set his password.

How could I do that avoiding duplicates? I mean.. preventing a user to have two table rows (one with user_id, first_name, email, etc) and another row just with Facebook information?

I know this is really poorly explained so please don't refrain to ask questions.


Awesome. I'll have a look!

no worries!

If you're interested there is also a CI library/module called a3m (marshmallow for CI2) which helps to integrate FB, Twitter, Google, Yahoo and OpenID login/registration. It takes a bit of hacking and research to suit your needs, but I got mine up and going in about 3 weeks (that's pt though, so perhaps 4 - 5 full 8hr days it took me).

What I did, was request the users email as a permission when they're logging in with the Facebook SDK. Then I checked to see if the user had already registered by checking the Facebook e-mail against the rows in the database -- and if so update the row with the fb_uid, etc. Also, I stored the access_token (but an extended one, since the 'offline_access' permission has been depreciated).

Hope this helps.

Yes that might work but only if your email is the same that you used to register to Facebook

It's the only feasible way I can see to be honest.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.