[SOLVED] Connexion login error

8 years 1 month ago - 8 years 1 month ago #279037 by activha
[SOLVED] Connexion login error was created by activha
Hello

I upgraded to all nightly build this morning and we now get the following error when trying to log in :

Message: Connection error: Response decoding failed: not array. Received text:

It seems that reloading the same page allows the user to be logged in correctly. But we have this message on every page where log in is required and user tries tog in.

I think it comes from a code auto action connecting to PAP software.

The code is as follows :

it only uses OnBeforeUserProfileEditDisplay without conditions
include_once("<span>/</span>var<span>/</span>www/html/affiliation/api/PapApi.class.php");
$Juser = CBuser::getUserDataInstance( "[user_id]" );


       // get data from CB
       $cbpapid = "[USERNAME]";
       $cbparentid = "[cb_codeparrainpartenaire]";
       
         // params info        
         $pap4Url = '[cb:config param="live_site" /]/affiliation/scripts/server.php';
         $pap4Username = "xxxxxx";
         $pap4Pwd = "xxxxxx";
         
    	try {
               $session = new Gpf_Api_Session($pap4Url);
               if (!$session->login($pap4Username, $pap4Pwd)) {
       				die("Message erreur :  ".$session->getMessage()); 
       			}
			   // get affiliate with pap id = USERNAME			
			   $affiliate = new Pap_Api_Affiliate($session);
			   $affiliate->setRefid($cbpapid, Pap_Api_Affiliate::OPERATOR_EQUALS );
			   try {
				 	$affiliate->load();
			   } 
			   catch (Exception $e) {
			   		//affiliate not exists needs to be registered on PAP

					// convert the user parameters to a format for the external application	
					$args = array();
					$args["email"] = "[EMAIL]";
					$args["fname"] = "[firstname]";
					$args["lname"] = "[lastname]";
					$args["refid"] = "[USERNAME]";
					$args["parentuserid"] ="[cb_parrain]";
					$args["password"] = "[cb_passaffiliation]";
					$args["data3"] = "[cb_address]";
					$args["data4"] = "[city]";
					$args["data6"] = "[cb_pays]";
					$args["data7"] = "[zipcode]";
					
					// create new affiliate
					$affiliate->setUsername($args["email"]);
					$affiliate->setPassword($args["password"]);
					$affiliate->setFirstname($args["fname"]);
					$affiliate->setLastname($args["lname"]);
					$affiliate->setRefid($args["refid"]);
					$affiliate->setParentUserId($args["parentuserid"]);
					$affiliate->setData(3,$args["data3"]);
					$affiliate->setData(4,$args["data4"]);
					$affiliate->setData(6,$args["data6"]);
					$affiliate->setData(7,$args["data7"]);	

					if(!$affiliate->add()) {				
       				die("Message: Merci de prendre contact avec nous, votre parrainage est inactif ".$session->getMessage()); 
       				}
       				//die('Message: '.$session->getMessage()); 
       			}

				//retrieve the parent id to update CB field
         		$parentid = htmlspecialchars($affiliate->getParentUserId());
         		$refid = htmlspecialchars($affiliate->getUserid());
				
				$Juser->cb_refid = $refid;
				$Juser->cb_codeparrainpartenaire = $parentid;
				$Juser->store();

			} 
		catch (Exception $e) {
    		die('Error while communicating with PAP: '.$e->getMessage());
       		}

Did you change something in latest cb or auto action nightly builds that could bring this error message ?

thanks for helping

Please Log in to join the conversation.

8 years 1 month ago #279042 by activha
Replied by activha on topic Connexion login error
I think the problem comes from [cb:config param="live_site" /] which is now respecting the https protocol and we need the plain http protocol

Is there a way to change the substitution to only get the http protocol ?

Please Log in to join the conversation.

8 years 1 month ago #279055 by krileon
Replied by krileon on topic Connexion login error
It always outputs whatever Joomla provides as the live_site. Specifically it's the result of JURI::base(). As you've access to PHP you can do a simple string replace as needed. Example as follows.

$pap4Url = str_replace( 'https', 'http', [cb:config param="live_site" /], 1 ) . '/affiliation/scripts/server.php';

You could also call Joomlas API directly, etc.. instead of using a substitution as needed.


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.

8 years 1 month ago #279056 by activha
Replied by activha on topic Connexion login error

It always outputs whatever Joomla provides as the live_site


We did not have this problem until last week and use this substitution all over the website.
So this has to be with a change that you introduced in latest builds somewhere.

I changed to :
         $pap4Url = '[cb:config param="live_site" /]/affiliation/scripts/server.php';
		$u =& JURI::getInstance( $pap4Url );
		$u->setScheme( 'http' );

               $session = new Gpf_Api_Session($u);

Hope it's ok ?
But I guess that we'll have the problem with substitution in other plugins such as paid subscriptions. Cannot you make the live site defaults to http ? and then use a string replace to https ?
Because 'm not sure that the JURI::base() always keeps the same protocol...

Please Log in to join the conversation.

8 years 1 month ago #279062 by krileon
Replied by krileon on topic Connexion login error

We did not have this problem until last week and use this substitution all over the website.
So this has to be with a change that you introduced in latest builds somewhere.

We didn't change anything. Most likely you changed a Joomla setting. Whether it's globally forcing HTTPS or setting your live_site URL in configuration.php. Could also be a change in a Joomla release. The code for CB to return live_site has been untouched for probably over a year now as there's no reason to touch it. It's possible something else installed could be modifying JURI::base() (CB does not).

Hope it's ok ?

Faster to just do a simple str_replace instead of building an entire URI object for it.

Cannot you make the live site defaults to http ? and then use a string replace to https ?

No, it is and always will be whatever Joomla has JURI::base() set to.

Because 'm not sure that the JURI::base() always keeps the same protocol...

It uses whatever scheme you're viewing the site as unless you've configured Joomla to globally force HTTPS or it uses whatever URL you specified as live_site in configuration.php.


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.

8 years 1 month ago #279104 by activha
Replied by activha on topic Connexion login error

Faster to just do a simple str_replace instead of building an entire URI object for it.


Well your code only gives a fatal error with : not being interpreted by string replace function.

Most likely you changed a Joomla setting. Whether it's globally forcing HTTPS or setting your live_site URL in configuration.php. Could also be a change in a Joomla release.


The only things that we changed are upgrade to the latest CB builds for CB, auto action, privacy, anti spam, conditionals and CBsubs

That's all, so I really cannot see why this scheme substitution problem and the antispam recaptcha problem that we have could come from anything else that CB :-)

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.277 seconds

Facebook Twitter LinkedIn