Jump to content

client login hook update WHMCS 7.2


sebsimappus

Recommended Posts

Hello,

 

I come to you because I have a problem since I can, I made the update in version 7.2 the client connection no longer works in javascript.

 

I attach the file hook hoping that someone will have an idea.

 

<?php
/**
* Example Hook Function
*
* Please refer to the documentation @ http://docs.whmcs.com/Hooks for more information
* The code in this hook is commented out by default. Uncomment to use.
*
* @package    WHMCS
* @author     WHMCS Limited <development@whmcs.com>
* @copyright  Copyright (c) WHMCS Limited 2005-2013
* @license    http://www.whmcs.com/license/ WHMCS Eula
* @version    $Id$
* @link       http://www.whmcs.com/
*/



if (!defined("WHMCS"))
die("This file cannot be accessed directly");


function existing_client_login() {


if($_POST['customemail']=='yes' && !empty($_POST['email']) && !empty($_POST['password'])) 
{


	 $command = "validatelogin";
	 $adminuser = "root";
	 $values["email"] = $_POST['email'];
	 $values["password2"] = $_POST['password'];
	 $values["stats"] = true;
	 $values["responsetype"] = "json";
	 $results = localAPI($command,$values,$adminuser);
	 if($results['result']=='success'){
		 $command = "getclientsdetails";
		 $values["clientid"] = $results['userid'];
		 $values["responsetype"] = "json";
		 $results = localAPI($command,$values,$adminuser);
		 //print_r($results);
		echo "Email exist";
	 }else{
		echo "false";
	 }

exit();
}
}



add_hook("ClientAreaPage",1,"existing_client_login");

?>

 

thank you in advance

 

cordially

Link to comment
Share on other sites

I think we need some more information to understand whats happening:

 

  • How does your javascript handle the result?
  • Were there any PHP errors?
  • Do you get "Email exist" or "false"?

Why are you passing stats to ValidateLogin? A different array should be used for each request. I know WHMCS has logged me out when I call functions incorrectly or POST to pages incorrectly - so maybe something like that is happening. Heres an example:

 

$values = [
   "email" => $_POST["email"],
   "password2" => $_POST["password"]
];

// .. do call to ValidateLogin 

$values = [
   "clientid" => $clientId,
   "email" => $email,
   "stats" => true
];

// .. do call to GetClientsDetails 

 

You could print_r the $results variable of validatelogin so we can verify it was a sucessful login?

Link to comment
Share on other sites

Hello,

 

Thanks for your feedback,

 

I attach the print_r, the file hook works and finds the valid identifier, only it is as if it no longer validate the connection.

 

POST [url]https://www.club.com/cart.php[/url]

200 OK
	679ms	
jquery.min.js (ligne 4)
EntêtesPostRéponseHTMLCookies

Array
(
   [result] => success
   [client] => Array
       (
           [userid] => 1
           [id] => 1
           [uuid] => 22300d03-788d-4d50-829e-6f82114e7802
           [firstname] => Séb
           [lastname] => ESSAI
           [fullname] => Séb ESSAI
           [companyname] => 
           [email] => sebsi@msn.com
           [address1] => 15 rue des moutons
           [address2] => 
           [city] => Niedermodern
           [fullstate] => Bas-Rhin
           [state] => Bas-Rhin
           [postcode] => 67800
           [countrycode] => FR
           [country] => FR
           [phonenumber] => 0600000000
           [password] => $2y$10$plZNYFvuczpekkLne8PHDufMj1f/UqAPfWN.JPGyUrR6AV7ZtbFdi
           [statecode] => Bas-Rhin
           [countryname] => France
           [phonecc] => 33
           [phonenumberformatted] => +33.00000000
           [billingcid] => 0
           [notes] => 
           [twofaenabled] => 
           [currency] => 1
           [defaultgateway] => 
           [cctype] => 
           [cclastfour] => 
           [gatewayid] => 
           [securityqid] => 0
           [securityqans] => 
           [groupid] => 0
           [status] => Active
           [credit] => 0.00
           [taxexempt] => 1
           [latefeeoveride] => 
           [overideduenotices] => 
           [separateinvoices] => 
           [disableautocc] => 
           [emailoptout] => 
           [overrideautoclose] => 
           [allowSingleSignOn] => 1
           [language] => french
           [lastlogin] => Date: 09/04/2017 19:26<br>IP Address: 82.227.45.205<br>Host: bar67-1-82-227-45-205
.fbx.proxad.net
           [customfields1] => on
           [customfields] => Array
               (
                   [0] => Array
                       (
                           [id] => 380
                           [value] => on
                       )

                   [1] => Array
                       (
                           [id] => 381
                           [value] => 
                       )

                   [2] => Array
                       (
                           [id] => 379
                           [value] => FR34 424059822
                       )

                   [3] => Array
                       (
                           [id] => 15
                           [value] => Google
                       )

               )

           [customfields2] => 
           [customfields3] => FR34 424059822
           [customfields4] => Google
           [currency_code] => EUR
       )

   [stats] => Array
       (
           [numdueinvoices] => 1
           [dueinvoicesbalance] => WHMCS\View\Formatter\Price Object
               (
                   [price:protected] => 231.49
                   [currency:protected] => Array
                       (
                           [id] => 1
                           [code] => EUR
                           [prefix] => € 
                           [suffix] =>  EUR
                           [format] => 1
                           [rate] => 1.00000
                       )

                   [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX}
                   [defaultCurrencyDescriptor:protected] => Array
                       (
                           [format] => 1
                           [prefix] => 
                           [suffix] => 
                       )

               )

           [income] => WHMCS\View\Formatter\Price Object
               (
                   [price:protected] => 0
                   [currency:protected] => Array
                       (
                           [id] => 1
                           [code] => EUR
                           [prefix] => € 
                           [suffix] =>  EUR
                           [format] => 1
                           [rate] => 1.00000
                       )

                   [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX}
                   [defaultCurrencyDescriptor:protected] => Array
                       (
                           [format] => 1
                           [prefix] => 
                           [suffix] => 
                       )

               )

           [incredit] => 
           [creditbalance] => WHMCS\View\Formatter\Price Object
               (
                   [price:protected] => 0
                   [currency:protected] => Array
                       (
                           [id] => 1
                           [code] => EUR
                           [prefix] => € 
                           [suffix] =>  EUR
                           [format] => 1
                           [rate] => 1.00000
                       )

                   [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX}
                   [defaultCurrencyDescriptor:protected] => Array
                       (
                           [format] => 1
                           [prefix] => 
                           [suffix] => 
                       )

               )

           [numoverdueinvoices] => 1
           [overdueinvoicesbalance] => WHMCS\View\Formatter\Price Object
               (
                   [price:protected] => 231.49
                   [currency:protected] => Array
                       (
                           [id] => 1
                           [code] => EUR
                           [prefix] => € 
                           [suffix] =>  EUR
                           [format] => 1
                           [rate] => 1.00000
                       )

                   [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX}
                   [defaultCurrencyDescriptor:protected] => Array
                       (
                           [format] => 1
                           [prefix] => 
                           [suffix] => 
                       )

               )

           [numDraftInvoices] => 0
           [draftInvoicesBalance] => WHMCS\View\Formatter\Price Object
               (
                   [price:protected] => 0
                   [currency:protected] => Array
                       (
                           [id] => 1
                           [code] => EUR
                           [prefix] => € 
                           [suffix] =>  EUR
                           [format] => 1
                           [rate] => 1.00000
                       )

                   [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX}
                   [defaultCurrencyDescriptor:protected] => Array
                       (
                           [format] => 1
                           [prefix] => 
                           [suffix] => 
                       )

               )

           [numpaidinvoices] => 1
           [paidinvoicesamount] => WHMCS\View\Formatter\Price Object
               (
                   [price:protected] => 9.99
                   [currency:protected] => Array
                       (
                           [id] => 1
                           [code] => EUR
                           [prefix] => € 
                           [suffix] =>  EUR
                           [format] => 1
                           [rate] => 1.00000
                       )

                   [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX}
                   [defaultCurrencyDescriptor:protected] => Array
                       (
                           [format] => 1
                           [prefix] => 
                           [suffix] => 
                       )

               )

           [numunpaidinvoices] => 1
           [unpaidinvoicesamount] => WHMCS\View\Formatter\Price Object
               (
                   [price:protected] => 231.49
                   [currency:protected] => Array
                       (
                           [id] => 1
                           [code] => EUR
                           [prefix] => € 
                           [suffix] =>  EUR
                           [format] => 1
                           [rate] => 1.00000
                       )

                   [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX}
                   [defaultCurrencyDescriptor:protected] => Array
                       (
                           [format] => 1
                           [prefix] => 
                           [suffix] => 
                       )

               )

           [numcancelledinvoices] => 2
           [cancelledinvoicesamount] => WHMCS\View\Formatter\Price Object
               (
                   [price:protected] => 52.53
                   [currency:protected] => Array
                       (
                           [id] => 1
                           [code] => EUR
                           [prefix] => € 
                           [suffix] =>  EUR
                           [format] => 1
                           [rate] => 1.00000
                       )

                   [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX}
                   [defaultCurrencyDescriptor:protected] => Array
                       (
                           [format] => 1
                           [prefix] => 
                           [suffix] => 
                       )

               )

           [numrefundedinvoices] => 0
           [refundedinvoicesamount] => WHMCS\View\Formatter\Price Object
               (
                   [price:protected] => 0
                   [currency:protected] => Array
                       (
                           [id] => 1
                           [code] => EUR
                           [prefix] => € 
                           [suffix] =>  EUR
                           [format] => 1
                           [rate] => 1.00000
                       )

                   [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX}
                   [defaultCurrencyDescriptor:protected] => Array
                       (
                           [format] => 1
                           [prefix] => 
                           [suffix] => 
                       )

               )

           [numcollectionsinvoices] => 0
           [collectionsinvoicesamount] => WHMCS\View\Formatter\Price Object
               (
                   [price:protected] => 0
                   [currency:protected] => Array
                       (
                           [id] => 1
                           [code] => EUR
                           [prefix] => € 
                           [suffix] =>  EUR
                           [format] => 1
                           [rate] => 1.00000
                       )

                   [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX}
                   [defaultCurrencyDescriptor:protected] => Array
                       (
                           [format] => 1
                           [prefix] => 
                           [suffix] => 
                       )

               )

           [numpaymentpendinginvoices] => 0
           [paymentpendinginvoicesamount] => WHMCS\View\Formatter\Price Object
               (
                   [price:protected] => 0
                   [currency:protected] => Array
                       (
                           [id] => 1
                           [code] => EUR
                           [prefix] => € 
                           [suffix] =>  EUR
                           [format] => 1
                           [rate] => 1.00000
                       )

                   [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX}
                   [defaultCurrencyDescriptor:protected] => Array
                       (
                           [format] => 1
                           [prefix] => 
                           [suffix] => 
                       )

               )

           [productsnumactivehosting] => 0
           [productsnumhosting] => 0
           [productsnumactivereseller] => 0
           [productsnumreseller] => 0
           [productsnumactiveservers] => 0
           [productsnumservers] => 1
           [productsnumactiveother] => 1
           [productsnumother] => 2
           [productsnumactive] => 1
           [productsnumtotal] => 3
           [numactivedomains] => 5
           [numdomains] => 5
           [numacceptedquotes] => 0
           [numquotes] => 0
           [numtickets] => 1
           [numactivetickets] => 1
           [numaffiliatesignups] => 0
           [isAffiliate] => 
       )

)
Email exist

 


jQuery("#loggingid").on('click', function () {
       jQuery('.error_msg').remove();
       if (jQuery("#loggedemail").val() == '') {
		jQuery("#loggedemail").css('border','1px solid red');
       } else if (jQuery("#loggedpass").val() == '') {
		jQuery("#loggedpass").css('border','1px solid red');
       } else {
		jQuery("#register-login").show();
		jQuery("#loggingid").hide();
           jQuery("#loginloading").show();
           $.post("cart.php", 'customemail=yes&email=' + jQuery("#loggedemail").val() + '&password=' + jQuery("#loggedpass").val(),
			function (data) {                      
				jQuery("#loginloading").hide();
				if (data == 'Email exist') {
					jQuery("#loginerror").css('display','none');
					jQuery("#loggedmessage").show();
					jQuery("#loginupdate").css('display','block');
					signupstep();
					recalcsummary();
				}
				else if (data == 'false') {
					jQuery("#loggingid").show();
					jQuery("#register-login").css('display', 'none');
					jQuery("#loginerror").css('display','block');
					jQuery('html, body').animate({scrollTop: jQuery("#loginerror").offset().top - 14}, 1000);
				}
			});
       }
   });

 

thank you in advance

Edited by sebsimappus
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated