2016-11-25 2 views
0

Nous utilisons actuellement auto auth et nous avons la méthode ci-dessous pour vous connecter automatiquement à l'aide de ce courriel, le problème est lorsque l'e-mail a un plus sign il ne sera pas connecter automatiquement.Whmcs auto auth

/** 
* @param $email Clients Email Address to Login 
* @param string $goto is a url endpoint where you want to redirect the user 
*/ 
public static function autoLoginUser($email, $goto = 'index.php?m=dashboard') 
{ 
    global $CONFIG; 

    /** 
    * Define WHMCS url and AuthKey from confguration.php 
    */ 
    $whmcsurl = $CONFIG['SystemURL'] . "/dologin.php"; 
    $autoauthkey = "Our auth key is here"; //$autoauthkey from configuration.php 

    $timestamp = time(); //Get current timestamp 
    $hash = sha1($email . $timestamp . $autoauthkey); //Generate Hash 

    /** 
    * Generate AutoAuth URL & Redirect 
    */ 
    $url = $whmcsurl . "?email=$email&timestamp=$timestamp&hash=$hash&goto=" . urlencode($goto); 
    header("Location: $url"); 
    exit; 
} 

Est-ce que quelqu'un a déjà essayé cela? Avoir une adresse e-mail normale fonctionne parfaitement, mais sur un e-mail contenant un signe plus, l'utilisateur ne se connectera pas automatiquement.

+0

pas sûr mais essayez de remplacer + dans le courrier électronique avec% 2B url d'échappement car WHMCS crée un bouchon de courrier électronique et il pourrait être un problème avec l'encodeur. –

+0

HI @LukaSvalina J'ai essayé celui-là mais ça n'a pas marché. Je vais poster ce qui fonctionne sur notre cas. –

Répondre

2

Je ne sais pas pourquoi il n'a pas été documenté dans whmcs mais le travail autour de nous parvenons à avoir est encoder l'e-mail comme le code suivant

/** 
* @param $email Clients Email Address to Login 
* @param string $goto is a url endpoint where you want to redirect the user 
*/ 
public static function autoLoginUser($email, $goto = 'index.php?m=dashboard') 
{ 
    global $CONFIG; 

    /** 
    * Define WHMCS url and AuthKey from confguration.php 
    */ 
    $whmcsurl = $CONFIG['SystemURL'] . "/dologin.php"; 
    $autoauthkey = "Our auth key is here"; //$autoauthkey from configuration.php 

    $timestamp = time(); //Get current timestamp 
    $hash = sha1($email . $timestamp . $autoauthkey); //Generate Hash 
    $email = 
    /** 
    * Generate AutoAuth URL & Redirect 
    */ 
    $url = $whmcsurl . "?email=".urlencode($email)."&timestamp=$timestamp&hash=$hash&goto=" . urlencode($goto); 
    header("Location: $url"); 
    exit; 
}