Loading...
 
Features / Usability

Features / Usability


Social Login unable to auto create user

posts: 68 United Kingdom

Hi,

I'm a total newbee and just installed Tiki over the weekend. I've managed to get a lot of things going already but I'm having difficult with the Facebook login.

I'm running version 19.0.

The FB app has been created and working fine with other applications but for Tiki I am getting these errors:

1. When click login with FB:
Possible cross-site request forgery (CSRF, or "sea surfing") detected. Operation blocked.

If I hit "Confirm Action" this error message pops up:

2. We were unable to create a new user with your Facebook account. Please contact the administrator.

I have gone through these links for the setup:

https://doc.tiki.org/Facebook-Tab
https://doc.tiki.org/Social-Networks
https://doc.tiki.org/External-Authentication

and unfortunately nothing shows up in the logs.

For the FB OAuth redirect I'm using the URL as follows: https://mydomain/tiki-socialnetworks.php?request_facebook


I wonder if someone can help? Thanks.

posts: 68 United Kingdom

I think I have figured out the second part of the issue....

It seems that Tiki isn't pulling any details from Facebook so initially an account of fb_ gets created and not fb_xxxxx which is what is supposed to happen.

I'm not sure if there is a setting for this or if the code needs to be updated because FB changed something again?

I still don't have an answer to the cross-site request issue though...


posts: 68 United Kingdom

One more quick update on this one in finding out the issue.

In the Tiki logs there is a message saying "Can't connect" to Facebook Graph. At least now the issue is clear, just need to figure the solution out!


posts: 68 United Kingdom

Bump anyone?

My project is kind of based around this feature so I'm really stuck without it. I am happy to test or try anything at this point as long as someone can suggest something :-)


posts: 400

Hi Kaya,

Sorry you're having problems. Just to confirm, you get the CSRF message after just clicking on the "Log in via Facebook" button?
Thanks,
lindon


posts: 68 United Kingdom

Yep that's correct.

I hit login via FB and bang: CSRF

Afterwards I hit "confirm" then in logs it shows: "cannot connect to facebookGraph"


posts: 400

Thanks! Will try to look at the CSRF part later today.
Regards,
lindon


posts: 400

Hmmm, I don't have that issue when testing locally. Will try on a remote server. In the meantime, what options on the Facebook tab of the social networks admin panel do you have set?
Thanks,
lindon


posts: 400

Hi Kaya,

The main thing is to delete lines 211 and 242 in /lib/socialnetworslib.php, which both have the following:

$ret = substr($ret, 3, strlen($ret) - 10);

Let me know if this doesn't work for you.


posts: 68 United Kingdom

Hi Lindon,

I actually downloaded the updated version of the socialnetworkslib.php file and pushed it to Tiki.

So this is what I have observed:

CSRF error gone!! :-)

Facebook login:

Error

Facebook profile information not retrieved

posts: 400

Hi Kaya,

I tried on a remote server and I wasn't able to recreate the issue. For me, logging in using facebook and automatically creating a user worked fine.

What options on the Facebook tab of the social networks admin panel do you have set?
Thanks,
lindon


posts: 68 United Kingdom

The options I've got enabled are as such:

  • Facebook Site Name
  • Application ID
  • Application Secret
  • Login Using Facebook
  • Auto Create Tiki User
  • Set user email from Facebook on creation.
  • Create a user tracker item on registration
  • First and last name tracker field IDs to set on creation { set to: 2,3 }

posts: 400

Using those same options I am not experiencing any issues. The user is created as well as the user tracker. Difficult to debug without more data regarding what's happening with your code. The key would be what's happening around lines 273 and 274 of /lib/socialnetworkslib.php, which has this code:

$access_token = $this->getFacebookAccessToken();
$fb_profile = $this->getFacebookUserProfile($access_token);

Would be good to know if the $access_token variable is getting a value and to see what the $fb_profile variable has. If you're not sure how to do that, you could insert these lines after the two lines quoted above if your site is not yet in production:

var_dump($fb_profile);
var_dump($access_token);
exit;

You should see a white screen with the variable values after trying to log in with Facebook. The fb_profile should have a class with the Facebook id, email, name, first name, last name. The access_token should be a very long random string of characters. If you are able to reply that info, especially what the fb_profile looks like (just the structure, not your data or tokens) that might help.


posts: 68 United Kingdom

Result is this:

NULL bool(false)


posts: 400

Okay, looks like the access token is not being created in the getFacebookAccessToken() method in /lib/socialnetworkslib.php. Please take out the code I asked you to put in, and place new code after row 221, which has the following in it:

$json_decoded_ret = json_decode($ret, true);

After that line, place the following:

var_dump(['ret' => $ret]);
var_dump(['json' => $json_decoded_ret]);
exit;

And try to log in using Facebook and let me know what the results are (eliminating any private data)


posts: 68 United Kingdom
After clicking on Login with FB I get a blank white page with no data on it ?
posts: 400

Okay, remove that code and try this after line 2017, which has the following:

$fp = fsockopen('ssl://graph.facebook.com', 443);

Add these lines:

var_dump(['fp' => $fp]);
exit;

posts: 400

And also:

var_dump(['url' => $url]);

at that same spot


posts: 68 United Kingdom
Same behavior, blank white screen
posts: 400

Okay then, try this just before line 207 (which had the $fb = fsockopen code):

var_dump(['url' => $url]);
exit;


Page: 1/6  [Next]