Facebook connect not logging in

Aug 25, 2012 at 3:09 PM

I have the Facebook connect widget displaying and the Facebook window pops up, I agree to let the app login with FB and the window disappears. However I don't then appear logged into my Orchard site?

 

Am I missing something obvious? I have set up my app id and secret in my Orchard settings.

Coordinator
Aug 26, 2012 at 11:54 AM

What happens after the login window disappears? Does the page redirects or reloads? Do you get any JS errors? Do you have any errors in the Orchard log?

Aug 26, 2012 at 5:13 PM

I am taken to the Orchard user registration screen. Looking at a script console the following message is displayed:-

"FB.init has already been called - this could indicate a problem"

This is just on the standard out of the box Orchard site. I created a layer with the  FB Connect widget on it and created a URL rule on the layer so it applied to the logon page.


Coordinator
Aug 26, 2012 at 7:21 PM
Edited Aug 26, 2012 at 7:21 PM

That FB init warning is no problem.

I tried your site and there is nothing wrong: after the user connects to the application he's taken to the normal registration page (this is since you haven't enabled "simple registration" where the user is only asked to provide a user name). This is necessary: fully automatic log-in is not possible, because by e.g. taking the user's FB name as the user name there can be naming clashes. I was able to register with FB.

Aug 26, 2012 at 8:13 PM

But the site doesn't show you as logged in? or do you mean I need to enable simple registration?

Coordinator
Aug 26, 2012 at 8:24 PM

Yes, because you first need to create an Orchard account. FB Suite Connect won't create an Orchard user account and log in the user as an Orchard user without user intervention because there is no way to guarantee the unicity of users without them choosing user names in the current Orchard user management solution.

After the account is created you'll be able to log in only by clicking "Connect with FB".

Aug 26, 2012 at 8:30 PM

So there are two scenarios if I understand correctly:-

 

1) Simple, the user connects via facebook and all we have available to us is a username, we won't know the email address of the user

2) Not simple, the user still have to go through the user creation process in Orchard as well as connecting with FB, however after creating the account they only need log in with Facebook from that point on?

 

Is there any way to just connect up with Facebook but we know the user's email address?

Coordinator
Aug 26, 2012 at 8:39 PM

You understand correctly, but even with simple registration you could get the user's e-mail address multiple ways, but these involve writing code in your own module:

  • Create you own registration logic (adding e.g. a textbox for an e-mail) in a custom controller and only use FB Suite Connect's services
  • Override FacebookConnectSimpleRegistration.cshtml, add a textbox for e-mail, then fish out its value from the HttpContext POST data by hooking into e.g. UserUpdated event of the IFacebookConnectEventHandler eventhandler (by implementing the interface)
  • Set FB permissions to also request the e-mail address of the user, then by hooking into the previously mentioned event handler request the user's FB data by making a call to the FB API, like FacebookConnectService.FetchMe() does.
Aug 26, 2012 at 9:05 PM

Currently I see no user entries in the Orchard DB for simple mode so I am not sure what the point of it is as I can't even tell if they are a user can I?

Coordinator
Aug 26, 2012 at 9:23 PM

I don't understand. If you enable simple registration, then users, after connecting to your app, will be able to enter a username, click register, then have a user account in Orchard. Only then, after registration is complete, will you see an entry corresponding to the new user in the DB.

Connecting to your app is one thing, and having an Orchard user account is another. When a user connects to your app it only means that your app (and so FB Suite) can fetch the user's credentials, but the user is not yet registered.

Sep 1, 2012 at 10:51 AM

I think I understand now, if I want it to work the way I thought it would then I would need to intercept the connect with FB part and create an account on their behalf, generating an Orchard username for them.

Coordinator
Sep 1, 2012 at 4:22 PM

Yes, but I highly dis-advice this due to the reasons mentioned.