Topic-icon Autologin not working immediately

14 years 4 months ago #18945 by paz
Greetings,

I have 4.1.2 installed and was looking on the release notes to see if the Jscript bug from Facebook was solved or not.

When autologin is enabled, and a known user lands on the site from facebook, they are not logged in. Again towards an older post I made, you have to refresh the page and then you are logged in. Still needing a solution on this.

I looked into the /com/lib/facebook.php script into the _performAutoLogin function.

$fbUserId = $this->getFbUserId();
$userMapModel = new JFBConnectModelUserMap();
$jUserId = $userMapModel->getJoomlaUserId($fbUserId);

$fbuserid returns something, but the mapping fails. So whether you are returning KNOWN FB user or not, the evaluation if ($jUserId) will always fail on the first try.

Is there a way to fix this, or is this still to do with the Jscript bug from Facebook? What I dont understand is if $fbuserid always returns a good value, the evaluation should never fail.

Thanks,
p.
The topic has been locked.
14 years 4 months ago #18947 by paz
Hmm, seems I was incorrect. On the first arrival page, it seems that $fbuserid is not known. I was pretty sure I was seeing it, but I must have had an existing session.

So I take it this is the same bug. Is there any intel on this subject if Facebook will:

a) fix the bug
b) refuse to acknowledge because they dont want autofacebook logins to work.

I could understand that (b) was the case because it means there is not explicit user action which says "yes i want to use my facebook login".

Just wondering because one way or another Im going to brute force this problem :-)
The topic has been locked.
Support Specialist
14 years 4 months ago #18968 by alzander
Paul,
If I described it as a bug in Facebook, I was a little off. Basically, they made a change late last year which changed the behavior of how things work. That feature change broke how JFBConnect was working to perform the auto-logins, now making it happen on the second page refresh. We have plans in the works to fix this in an upcoming release (4.2, if not a 4.1.x release sooner). I'll gladly say it's a bug in JFBConnect at this point, but something that's going to take a little more investigation to find the fool-proof implementation we need to make sure it works across everyone's sites.

If you're going to brute force something, let's do it in a way that will help us both. The below code, I think will do what you're looking for. It's completely untested, so may not work.. however, it will be similar to what we're planning to do but we'll likely put more checks in place. We'd love to have your feedback positive or negative on this so that we can better refine it for the upcoming release.

Changes:
In /plugins/system/jfbcsystem/jfbsystem.php, around like 167, you'll see:
$subs .= "\njfbc.social.googleAnalytics.trackFacebook();";
Add the following line right after that:
$subs .= "\nFB.Event.subscribe('auth.login', jfbc.login.login_custom());";
It's possible that's all you will need. It's also possible that this will cause some oddness when a user actually clicks the Login With Facebook button.

Hopefully though, it's that simple. Please let us know what you find though!

Thanks,
Alex
The topic has been locked.
Support Specialist
14 years 4 months ago #18970 by alzander
Paul,
I was wrong. Add the following line:
$subs .= "\nFB.Event.subscribe('auth.login', jfbc.login.login_button_click);";
The other one above would still probably work, but would flash the login box popup briefly.. not something you want :)

Keep us posted,
Alex
The topic has been locked.
14 years 4 months ago #18992 by paz
Wow, fantastic!! This works extremely well!

As far as I can tell there is no weirdness. The following state/reactions occur:

a) Facebook logged in/unknown joomla user: Landing page, redirect to registration form. After, redirected to original landing page
b) Facebook logged in/known user: Landing page, refreshes that page so logged in
c) Facebook not logged in: No weirdness at all. Normal facebook login works fine


What I've added which also works nice is a notification of what is happening for the user.

On components/com_jfbconnect/libraries/facebook.php I added the following after line 171 after (// Check if they should be logged in):

echo '<div style="width: 100%; color: #000000; background-color: red; font-size: 20px; font-weight: bolder;">Facebook login detected. Now redirecting</div>';

This will at least let the user know whats happening. Code can be done much nicer, im searching for some div/jscript that will make a modal popup.

Thanks Alex, much appreciated
p.
The topic has been locked.
Support Specialist
14 years 3 months ago #19110 by alzander
Paul,
I responded to this earlier, but unfortunately, we had a server outage which actually caused a small loss of data including my post response. Never a good thing, and thankfully the first time that's ever happened in over 3 years.

Anyways, just wanted to finalize this thread (again). I'm very glad to hear the above worked and that you don't see any issues. We're definitely working on more fully implementing this in the 4.2 release. The above code basically ignores the "Auto-login" setting in JFBConnect. We'll obviously need to check that is enabled before auto-logging in as well as some other checks to make sure all the different modes work properly.

If you run into any issues with this setting over time, we'd definitely like to hear about it. I can't think of anything off hand, but Facebook integration has many moving parts, so it's always possible :)

Best of luck,
Alex
The topic has been locked.
14 years 3 months ago #19516 by paz
Hi Alex,

It is working beautifully. Only problem is that new users to the site get redirected away from the landing page. This is not a bad thing, except that your average internet user has a very short attention span.

What I would love most in the future is this option to be implemented and when catch/redirecting a new (unknown) facebook user, the form is done in a modal window above the page instead of a full redirect.

In my case the landing page is a live streaming video with chat, so taking the user away is counterproductive. Having it in a modal popup would allow them to continue streaming and decide to register or not. If they do register, a refresh of the page now has their full facebook login showing in the chat.

p.
The topic has been locked.
14 years 3 months ago #19679 by paz
Alex, Ive been thinking. This workaround youve offered me is great. However its impacting my conversion process by forcing all facebook users in a path.

Ideally I need to continue allowing users to register if they want. So is it possible that this redirect is only performed for known users on the site?

For the time being Ive removed the code because uesrs dont like being railroaded to a place they didnt ask, ie unknown FB users ending up on a register page.

Thanks for the great support,
p.
The topic has been locked.
Support Specialist
14 years 3 months ago #19720 by alzander
Paul,
Sorry for not responding sooner. I'll try to answer each question best, though there may not be an ideal solution, I think what you have is working better than you think..

Only problem is that new users to the site get redirected away from the landing page.

This would only be for users that have installed your application (authenticated through Facebook) but not actually gone through your registration process. If someone who's logged into Facebook, but hasn't authenticated your application, visits, they shouldn't be taken on this path. For your testing purposes, I can see why you see this more often (you delete the J! user, but are still authenticated through Facebook). Most users won't see this though unless they didn't convert, like you mention...

For testing as a 'clean' user, make sure you both delete any J! accounts associated with the user and in Facebook, go to Account Settings -> Apps and remove the application. That will de-authenticate, so you can test as a FB user that never authenticated.

This workaround youve offered me is great. However its impacting my conversion process by forcing all facebook users in a path.

Just to re-say it, all Facebook user's don't go down this path.. just the ones who previously haven't converted.

So is it possible that this redirect is only performed for known users on the site?

Not sure what you mean by this.. if you mean users that already have J! accounts, they shouldn't go to the reg page anyways.. if it's for users that haven't created an account but have authenticated your FB app, that should be what's happening now.

Hopefully, that explains a little bit more. There are a few options I can see:
1) Change the User Creation setting to "Facebook User Only". This will automatically create the Joomla user and skip the reg page altogether.
2) Modify the Login/Register page of JFBConnect to have a big notice at the top explaining why to register and how they got to that page.

Hope that explains, but if you have other questions, let me know,
Alex
The topic has been locked.
14 years 3 months ago #19742 by paz
Ok, thats interesting. I have experimented and it does work quite well.

I think in terms of future functionality it may be useful to give that Facebook Only user an option to create a local site account and merge them. Because even though you cant login using that email address, it does technically exist in Joomla.

I think its a nice idea that a facebook user can "tour the site" as their FB identity and be given a reason to migrate the details into a real local account.

p.
The topic has been locked.