Loading...
 
Skip to main content

Features / Usability


Social Login unable to auto create user

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-TabQuestion
https://doc.tiki.org/Social-NetworksQuestion
https://doc.tiki.org/External-AuthenticationQuestion

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_facebookQuestion


I wonder if someone can help? Thanks.

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...


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!


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 😊


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


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"


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


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


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.


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

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


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 }

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.


Result is this:

NULL bool(false)


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)


After clicking on Login with FB I get a blank white page with no data on it ?

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;

And also:

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

at that same spot


Same behavior, blank white screen

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

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


Page: 1/6  [Next]