× Joomla Facebook Connect support forum

Topic-icon How to allow FB login only when existing CB users are defined?

Active Subscriptions:

None
Hello,

We would like to configure JFBConnect so that the "Login with Facebook" only works with users pre-defined in Community Builder. We do not want to allow new CB registrations via the "Login with Facebook" link. We only want to allow existing members to login to our website through Facebook whose e-mail addresses are already in CB. We are a private club and do not want new registrations from the general public.

Is this possible? I cannot seem to get it working properly. I have "Registration flow" set to "Automatic", and "Skip Joomla User Activation" set to "no". In Global Configuration, I have "Allow user registration" to set to "no". If a visitor logs in to the website with an unknown Facebook account (no matching e-mail address in CB), then JFBConnect reports:

"An error occurred. Please try again later."

or

"Your registration process is not yet complete! Please check again your email for further instructions that have just been resent. If you don't find the email, check your spam-box. Make sure that your email account options are not set to immediately delete spam. If that was the case, just try logging in again to receive a new instructions email."

Even though the foreign user is denied login to our website (which is what we want), JFBConnect still creates an automatic account for them in CB. We do not want any CB account to be created, preferably with a custom error message stating that we are a "members only" club instead of the canned messages above.

Any help that you can provide would be most helpful!

Thanks,
Tom Hammond
The topic has been locked.
Support Specialist
Tom,
We don't have a setting to disable registrations altogether. However, it should be pretty easy to add a little bit of code to do what you're looking for. Please try the following:
1) In the Configuration area of JFBConnect, set the "Registration Flow:" to "Normal Registration". That simply helps with the code change below..
2) In the /components/com_jfbconnect/controller.php file, at line 72, you should see the following 2 lines of code:
if ($configModel->getSetting('create_new_users') && $jUserId == null)
{ # User not in system, create new users setting enabled. Redirect to the login/register form
Modify it as below by adding the few lines shown below:
if ($configModel->getSetting('create_new_users') && $jUserId == null)
{ # User not in system, create new users setting enabled. Redirect to the login/register form
   $app->enqueueMessage("We couldn't find your account. You must be a member to login.", 'error');
   $app->redirect('index.php'); // Replace with any URL you should send users to that fail logging in
Leave all the other code below this in place.

That *should* do what you're looking for, but obviously test.. a lot :)

Let us know if that helps, or you run into other issues!

Thanks, and good luck,
Alex
The topic has been locked.
Active Subscriptions:

None
Hi Alex,

Thanks for the fast reply! I am now testing the code to see how it works. So far, so good!

Tom
The topic has been locked.
Support Specialist
Tom,
Changing your email in CB after you've already connected using Facebook won't do anything. JFBConnect creates a 'mapping' between the Facebook user and the Joomla/CB account. After that, when you login with Facebook, you'll always log into that account. Otherwise, if a user were to change their own email on the front-end, when they return, they would be forced to reconnect everything, which isn't very user friendly.

If you really want to test with an existing account, you should change the CB email -and- delete the User Map row for that user in the JFBConnect UserMap area.

Try that out, and let us know how it goes. If you run into issues though, you know where to find us :)

Alex
The topic has been locked.
Active Subscriptions:

None
Hi Alex,

I am sorry for the previous post; I did not think to look that my account was already created in the User Map area. I deleted my entry there and now it is working better. Sorry about that!

So far the code modification is working well. Thank you so much!
Tom
The topic has been locked.
Support Specialist
No need to apologize at all. Facebook integration is complex, and we have no problem explaining things to our users. Our job is to make things simple, however we can.

Glad it's working, and I really don't think you should run into any issues with the code above. If you do though, you know where to find us.

Finally, if you haven't already, please consider leaving a rating and review on the Joomla Extension Directory for JFBConnect, or our support. It's certainly not required, but very appreciated!
extensions.joomla.org/extensions/social-...ook-integration/7215

Best of luck,
Alex
The topic has been locked.