Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

...

With the AutoLoginShare plugin you can connect your slave HostBill instances into master using master's API key. Once client will attempt to log-in into slave, it will first check whether login details are valid for master. If login details are OK in master, but client does not exist in slave, AutoLoginShare will sync client data, and log client in. If login details are NOT OK in master, module will fallback onto local authentication (so your slave HostBills can have local customer base). Additionally AutoLoginShare can block customer registration on slave HostBill, so only master customers can log-in.

...

To update to newer version you will just have to repeat step 1 & 2, or check Auto-Update plugin built into your HostBill for one click updates.

MASTER API settings

...

After generating API key in your MASTER HOSTBILL→ adminarea → Settings → Security → API Access, you can limit ACL to two functions: getClientDetails & verifyClientLogin

Module Configuration

...

After activating your module in SLAVE HostBill you need to provide:

  1. URL to your MASTER HostBill adminarea
  2. API ID from your MASTER HostBill
  3. API KEY from your MASTER HostBill
  4. Optionally, you can disable client registration in SLAVE HostBill by enabling block_registrations
  5. Tick Check for paid if you want to enable only the clients who had paid for something to login to your Master HostBill 

Code sample: Login customer

...

Code sample below is in PHP using cURL.

Sample log-in code


<?php
 
// Get cURL resource
$ch = curl_init();
// Set AutoLogin url
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
// Data to post:
$email= "user@email.com"; //Client's email address
$duration = "160"; //Time in seconds for how long user login link will work
$secret = "SECRET_CODE"; //Secret code set in module configuration (in previous step)
$hash = md5($email.$secret.$duration); //Verification string
 
$body = http_build_query([
    'email'=>$email,
    'duration'=>$duration,
    'hash'=>$hash,
]); //data to post
 
// Set POST data
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
 
// Send the request & save response to $resp
$resp = curl_exec($ch);
 
if(!$resp) {
  die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
} else {
   $array = json_decode($resp,true);
   if($array['success']) {
        $login_url = $array['login_url'];  //url to link customer to HostBill
        $token = $array['token']; //token we can use to log user out
   } else {
    die('Error: "' . $array['error'] .'"');
   }
}
 
curl_close($ch);


Code sample: Logout customer

...

Code sample below is in PHP using cURL.

Sample log-out code


<?php
 
// Get cURL resource
$ch = curl_init();
// Set AutoLogin url
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
// Data to post:
$token = ""; //Login token returned upon user auto-login (previous step)
 
$body = http_build_query([
    'token'=>$token
]); //data to post
 
// Set POST data
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
 
// Send the request
$resp = curl_exec($ch);
curl_close($ch);