[SOLVED] Auto-approving users from external login

11 years 4 months ago - 11 years 3 months ago #151127 by hebakko
Hey,

I'm building a site for a customer that has an external user database he wishes to enable as well on his site.

Basically the setup currently is that a user can either register on his Joomla site with Community Builder or get authenticated via a php curl post.

The site is wanted to function so, that a user don't have to confirm his email after registering, and it works well for users who register via the registration on the site. (Community builder registration).

However, I would also need to get the auto-approve working for user who register via the external database. The code I'm using is somewhat identical to the Joomla's gmail authentication plugin, only difference is that the curl post url is different. Pasting here what the code does in the end once a user has been successfully identified from the external database:

if ($success)
{

$response->status = JAUTHENTICATE_STATUS_SUCCESS;
$response->error_message = '';
$response->email = $aResponse;
$response->fullname = utf8_encode($aResponse . ' ' .$aResponse);

}
else
{
$response->status = JAUTHENTICATE_STATUS_FAILURE;
$response->error_message = 'Failed to authenticate: ' . $message;
}


As far as I know I should add something to the code to make the user auto-approved in community builder, since after a site user has succesfully logged in to Joomla from the external database and attempts to view his profile he gets an error that the account has not yet been approved by a moderator, even though the accounts should be automatically approved.

So, my question is, how to enable the users logging to the site with an external database to become automatically approved? Since I've noticed it requires some hacking to the login / registration.

Thanks!

Please Log in to join the conversation.

11 years 4 months ago - 11 years 4 months ago #151181 by krileon
Replied by krileon on topic Re: Auto-approving users from external login
I see your cURL response code, but what is the code responsible for registering the user? Are they registered from the site directly on frontend or backend? Are they added directly to CB with a database query? CB has existing API for login and for registration, but don't think either/or would be sufficient as they're not designed for external use. Would be better to advise knowing the registration process.


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 to join the conversation.

11 years 4 months ago #151187 by hebakko
Replied by hebakko on topic Re: Auto-approving users from external login
Hey and thanks for your response.

The code responsible for registering the user to the site is Joomla default code (haven't touched it so not even sure where it is located yet) and thus the user is registered to Joomla not to Community Builder directly. However, the new user details get synchronized to CB automatically as well upon registering.

My knowledge of Joomla code is not very high yet so I'll paste the rest of my authentication code for you:

<?php
/**
* Package info etc.
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );

jimport( 'joomla.plugin.plugin' );

/**
* MY Authentication Plugin
*
* @package Joomla
* @subpackage JFramework
* @since 1.5
*/
class plgAuthenticationHanken extends JPlugin
{
/**
* Constructor foobar
*/
function plgAuthenticationMYSITE(& $subject, $config) {
parent::__construct($subject, $config);
}

/**
* This method should handle any authentication and report back to the subject
*
* @access public
* @param array $credentials Array holding the user credentials
* @param array $options Array of extra options
* @param object $response Authentication response object
* @return boolean
* @since 1.5
*/

function onAuthenticate( $credentials, $options, &$response )
{
$message = '';
$success = 0;
if(function_exists('curl_init'))
{
if(strlen($credentials) && strlen($credentials))
{
$curlHandle = curl_init();

After this the Curl works and gives the user a response whether the login was successful or not as I pasted earlier.

The users are registering to the site from frontend by simply typing their external username and password to the CB login fields. This is enabled from the CB backend by choosing Login field type to be:
Username, email or enabled CMS authentication plugins.

Hope this info helps a bit.

Please Log in to join the conversation.

11 years 4 months ago #151215 by krileon
Replied by krileon on topic Re: Auto-approving users from external login

the user is registered to Joomla not to Community Builder directly

This would be the problem. Users need to be registered through CB in order to properly be created within CB otherwise they'll be missing information such as approval and confirmation.

CB actually has API for registration and login. Best examples provided is our Facebook and Twitter plugins where such API is actively being used. All need be is to query the external database to ensure the input information is correct and you could then create and login that user through the API directly to CB.


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 to join the conversation.

11 years 4 months ago #151249 by hebakko
Replied by hebakko on topic Re: Auto-approving users from external login
Okey thanks,

I will look for an examples from the Facebook plugin.

Please Log in to join the conversation.

11 years 4 months ago #151273 by krileon
Replied by krileon on topic Re: Auto-approving users from external login
Please do let me know if you need any further information. Is possible to provide "code chunks" as examples. You can also review the tutorials found on my personal site at the following URL.

www.allmysocials.com/tutorials


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 to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.197 seconds

Facebook Twitter LinkedIn