Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

OpenId Login

8 years 2 months ago #284733 by versiliberi
OpenId Login was created by versiliberi
I need to allow my users to login in Community Builder with an OpenId Provider.
How can I achieve it?

Thank you.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48457
  • Thanks: 8280
  • Karma: 1443
8 years 2 months ago #284754 by krileon
Replied by krileon on topic OpenId Login
We don't have an OpenID provider for CB Connect. You can try using a Joomla authentication plugin for OpenID if one exists as CB supports Joomla authentication plugins by setting "Login Method" to "Username, Email Address, or CMS Authentication Plugins" within CB > Configuration > General.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

8 years 2 months ago #285033 by versiliberi
Replied by versiliberi on topic OpenId Login
Ok, I've bought this extension to get the OpenId login:
www.virtueplanet.com/extensions/vp-advanced-user

However, it extends the Joomla user login but it doesn't integrate automatically in Community Builder. To connect "VP Advanced User" and "Community Builder" I've written a small Joomla plugin, that I attach to this post.

File Attachment:

File Name: syncusers.zip
File Size:1 KB


This is the main code:

class PlgUserSyncusers extends JPlugin
{
public function onUserAfterSave($data, $isNew, $result, $error)
{
$database = JFactory::getDbo();
$sql_sync = "INSERT IGNORE INTO #__comprofiler(id,user_id) SELECT id,id FROM #__users";
$database->setQuery($sql_sync);
$database->query();

}
}

It works... but... is this approach correct? Can the above code improved or is it fine? I need that the users are automatically registered (if they are new), approved and logged in.

In particular, I noted that there is a more complex "syncUsers()" method in the class "CBController_default" in the file /administrator/components/com_comprofiler/controller/controller.default.php: is it better if I call this syncUsers() from my plugin? If yes, how can I do it?

Thanks.
Attachments:

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48457
  • Thanks: 8280
  • Karma: 1443
8 years 2 months ago #285065 by krileon
Replied by krileon on topic OpenId Login
That does not synchronize users correctly. You need to use CB API and properly register the user using CB API instead of Joomla API. I can not help you with custom coding. That extension has no mention of CB compatibility so am unsure why you chose to use it.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

8 years 2 months ago #285078 by versiliberi
Replied by versiliberi on topic OpenId Login
Thank you for your reply,
I chose VP Advanced User extension (and I customized its code) because it's the only one that I found full compatible with my OpenId provider

I rewrited the code of my Joomla plugin to sync the users of Joomla and CB: can you say me if now the approach is correct? I tried to fellow the code of the native syncusers() function of CB. Thank you.

// no direct access
defined( '_JEXEC' ) or die;

include_once( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' );
use CBLib\Language\CBTxt;
cbimport( 'cb.database' );

class PlgUserSyncusers extends JPlugin
{
public function onUserAfterSave($data, $isNew, $result, $error)
{
global $_CB_database, $_CB_Backend_Title, $ueConfig;

try {

// 0a. delete user table for bad rows
$sql = "DELETE FROM #__users WHERE id = 0";
$_CB_database->setQuery($sql);
$_CB_database->query();

// 0b. delete comprofiler table for bad rows
$sql = "DELETE FROM #__comprofiler WHERE id = 0";
$_CB_database->setQuery($sql);
$_CB_database->query();

// 1. add missing comprofiler entries, guessing naming depending on CB's name style:
switch ( $ueConfig ) {
case 2:
// firstname + lastname:
$sql = "INSERT IGNORE INTO #__comprofiler(id,user_id,lastname,firstname) "
." SELECT id,id, SUBSTRING_INDEX(name,' ',-1), "
."SUBSTRING( name, 1, length( name ) - length( SUBSTRING_INDEX( name, ' ', -1 ) ) -1 ) "
." FROM #__users";
break;
case 3:
// firstname + middlename + lastname:
$sql = "INSERT IGNORE INTO #__comprofiler(id,user_id,middlename,lastname,firstname) "
. " SELECT id,id,SUBSTRING( name, INSTR( name, ' ' ) +1,"
." length( name ) - INSTR( name, ' ' ) - length( SUBSTRING_INDEX( name, ' ', -1 ) ) -1 ),"
." SUBSTRING_INDEX(name,' ',-1),"
." IF(INSTR(name,' '),SUBSTRING_INDEX( name, ' ', 1 ),'') "
. " FROM #__users";
break;
default:
// name only:
$sql = "INSERT IGNORE INTO #__comprofiler(id,user_id) SELECT id,id FROM #__users";
break;
}
$_CB_database->setQuery($sql);
$_CB_database->query();

$sql = "UPDATE #__comprofiler SET `user_id`=`id`";
$_CB_database->setQuery($sql);
$_CB_database->query();

// 2. remove excessive comprofiler entries (e.g. if admin used mambo/joomla delete user function:
$sql = "SELECT c.id FROM #__comprofiler c LEFT JOIN #__users u ON u.id = c.id WHERE u.id IS NULL";
$_CB_database->setQuery($sql);
$users = $_CB_database->loadResultArray();

}
catch ( RuntimeException $e ) {
return;
}

}
}

File Attachment:

File Name: syncusers_...8-27.zip
File Size:2 KB
Attachments:

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48457
  • Thanks: 8280
  • Karma: 1443
8 years 2 months ago #285121 by krileon
Replied by krileon on topic OpenId Login
No, that's not correct. You're just triggering database inserts. CB users should be registered or saved through API calls. The code used by CB > Tools is a last-resort fix for desynced installs and is not an example of creating users through API. See the below for an example of registering a user with CB API.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18362-registering-a-user-through-cb-api


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum