Advertisement
langbung01

Preauth frontend

Aug 5th, 2018
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1.     public function zimbraPreauth(){
  2.         $PREAUTH_KEY = env("PREAUTH_KEY");
  3.         $domain = env("MAIL_DOMAIN");
  4.         $backend_ip = env("BACKEND_IP");
  5.         $id = Auth::id();
  6.         $http = new client;
  7.         $response = $http->request('GET',$backend_ip.'/api/account_info/'.$id, [
  8.             'allow_redirects' => false
  9.         ]);
  10.         $body = json_decode($response->getBody(), true);
  11.         $email = $body["data"]["thai_email"];
  12.         $timestamp=(time()*1000);
  13.         $preauthToken=hash_hmac("sha1",$email."|name|0|".$timestamp,$PREAUTH_KEY);
  14.         $path = "/service/preauth?";
  15.         $var = http_build_query([
  16.             'account'     => $email,
  17.             'expires'  => '0',
  18.             'timestamp' => $timestamp,
  19.             'preauth' => $preauthToken,
  20.         ]);
  21.         $preauthURL = "{$domain}{$path}{$var}";
  22.         return redirect($preauthURL);
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement