Mapping Facebook accounts to local accounts

Dave Cohen - March 6, 2008 - 16:31
Project:Drupal for Facebook
Version:5.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Dave Cohen
Status:closed
Description

Currently, a limitation of Drupal for Facebook is that, while it will create a local (Drupal) account when Facebook users add an app, it does not help link the account of an app user to a local account that already exists. I'm working to improve the situation, and this issue will track progress.

The patch attached here needs work, but it shows the direction things are headed. (The patch includes a few changes not relevant to user mappings, I apologize for that, but I included all my recent changes to make sure I did not leave anything out.) The most important part of the patch is in fb_user_user(). There, when a user logs in or registers, the module creates the authmap entry necessary to link the accounts.

I'm also working to provide a link from the drupal URL to quickly add the app and associate the accounts, but this is a work in progress and not quite working yet.

There are some unrelated changes to stylesheets which work around IE bugs on canvas pages.

AttachmentSize
fb_user_changes.diff22.65 KB

#1

domidc - March 7, 2008 - 13:47

I ve been working on a little module that maps the fb account to the user account on the drupal site.
It works but it's not well integrated into the fb module.

AttachmentSize
facebook_sync.zip 1.65 KB

#2

Dave Cohen - March 18, 2008 - 02:58
Status:active» needs review

Here's a cleaner patch that applies to the very latest modules/fb/ (do a cvs update). There's some good progress here. The code is new and I may not have tested every permutation. I've also left a bunch of debug output the screen and watchdog. However I'm eager to get folks using this so I'm submitting anyway.

This patch adds...

  • If you send a user to apps.facebook.com/myapp/user/login on a and they log in, an authmap will be created connecting their facebook account to their local account.
  • Same thing for user/register. This means you can configure your app not to create accounts automatically. Instead you have the users register (in addition to adding the app), and account creation proceeds as normal for your site.
  • If a user adds the app, they are presented with a form which allows them to either log in, register, or neither (continue and use the app)
  • You can send a logged in user to apps.facebook.com/myapp/fb_user/sync. Once there, they are prompted to add the app (unless added already) then the local account and facebook account are automatically mapped together. Sweet! (this was a real pain to get working, btw).
AttachmentSize
fb_user.diff 26.7 KB

#3

Dave Cohen - March 18, 2008 - 03:07

To domidc,

Thanks for sharing your module. Its short and sweet but I went a different direction because I did not want to introduce any new forms. For example I have a site which alters the login form and I wouldn't want to have to start altering yet another login form if you know what I mean. Also I did not want to force the user to have to type their username and password again, they've already logged into the drupal site and facebook. And there are times when it's possible to avoid it.

And just nitpicking, better to use user_set_authmaps rather than write to the table directly.

#4

domidc - March 25, 2008 - 18:59

You're right. Now everything is well integrated. The automatic mapping is great.
Thanks!

#5

Dave Cohen - March 27, 2008 - 22:09
Status:needs review» fixed

Patch checked in.

#6

Anonymous (not verified) - April 10, 2008 - 22:11
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.