180,7 → 180,7 |
} |
|
protected function getUserFromCookie(){ |
$cookie = $_COOKIE[$this->config['authentification']['cookieName']]; |
$cookie = $_COOKIE['tb_auth']; |
|
if ($cookie){ |
// Récupération de l'id et email de l'utilisateur connecté |
187,6 → 187,11 |
$tokenInfos = $this->decodeToken($cookie); |
|
$token = $this->refreshToken($cookie)['token']; |
// $service = "auth/identite?token="; |
// $url = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], $service).$cookie; |
// |
// $json = $this->getDao()->consulter($url); |
// $token = json_decode($json, true)['token']; |
|
$user = [ |
'id' => $tokenInfos['id'], |
200,12 → 205,13 |
} |
|
protected function refreshToken($token) { |
// $verificationServiceURL = 'https://www.tela-botanica.org/service:annuaire:auth/identite'; |
$service = "auth/identite?token=" . $token; |
$verificationServiceURL = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], $service); |
|
// $verificationServiceURL .= "?token=" . $token; |
$ch = curl_init(); |
|
$cookie = $this->config['authentification']['cookieName'].'='.$token; |
// $timeout = 5; |
$cookie = 'tb_auth='.$token; |
|
$headr = array(); |
$headr[] = 'Cookie: ' . $cookie; |
219,12 → 225,18 |
// ]); |
curl_setopt($ch, CURLOPT_COOKIE, $cookie); |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
// curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); |
// équivalent de "-k" |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
$response = curl_exec($ch); |
|
// if ($response === false) { |
// echo 'Erreur cURL : ' . curl_error($ch); |
// } else { |
// echo 'Réponse : ' . $response; |
// } |
|
curl_close($ch); |
|
return json_decode($response, true); |