public function zimbraPreauth(){
$PREAUTH_KEY = env("PREAUTH_KEY");
$domain = env("MAIL_DOMAIN");
$backend_ip = env("BACKEND_IP");
$id = Auth::id();
$http = new client;
$response = $http->request('GET',$backend_ip.'/api/account_info/'.$id, [
'allow_redirects' => false
]);
$body = json_decode($response->getBody(), true);
$email = $body["data"]["thai_email"];
$timestamp=(time()*1000);
$preauthToken=hash_hmac("sha1",$email."|name|0|".$timestamp,$PREAUTH_KEY);
$path = "/service/preauth?";
$var = http_build_query([
'account' => $email,
'expires' => '0',
'timestamp' => $timestamp,
'preauth' => $preauthToken,
]);
$preauthURL = "{$domain}{$path}{$var}";
return redirect($preauthURL);
}
Comments