2016-11-25 62 views
0

目前,我们正在使用auto auth,我们有下面的方法登录的用户自动使用有电子邮件,问题是当电子邮件有一个plus sign它不会自动登录。WHMCS自动权威性

/** 
* @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; 
} 

有没有人试过这个?有一个正常的电子邮件地址完美的作品,但对包含加号的电子邮件,它不会自动登录用户。

+0

不知道,但尝试用%2B替换+的电子邮件当WHMCS从电子邮件创建slug时逃脱url,这可能是编码器的问题。 –

+0

你好@LukaSvalina我试过那个,但它没有工作。我会发布对我们的案件有用的东西。 –

回答

2

我不知道为什么它没有在WHMCS证明,但我们周围的管理有工作编码的电子邮件如下面的代码

/** 
* @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; 
}