Subversion Repositories eFlore/Applications.cel

Rev

Rev 3967 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3967 Rev 3969
Line 178... Line 178...
178
		}
178
		}
179
		return base64_decode(strtr($input, '-_', '+/'));
179
		return base64_decode(strtr($input, '-_', '+/'));
180
	}
180
	}
Line 181... Line 181...
181
 
181
 
182
	protected function getUserFromCookie(){
182
	protected function getUserFromCookie(){
Line 183... Line 183...
183
		$cookie = $_COOKIE['tb_auth'];
183
		$cookie = $_COOKIE[$this->config['authentification']['cookieName']];
184
		
184
		
185
		if ($cookie){
185
		if ($cookie){
Line 186... Line 186...
186
			// Récupération de l'id et email de l'utilisateur connecté
186
			// Récupération de l'id et email de l'utilisateur connecté
187
			$tokenInfos = $this->decodeToken($cookie);
-
 
188
			
-
 
189
			$token = $this->refreshToken($cookie)['token'];
-
 
190
//			$service = "auth/identite?token=";
-
 
191
//			$url = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], $service).$cookie;
-
 
Line 192... Line 187...
192
//
187
			$tokenInfos = $this->decodeToken($cookie);
193
//			$json = $this->getDao()->consulter($url);
188
			
194
//			$token = json_decode($json, true)['token'];
189
			$token = $this->refreshToken($cookie)['token'];
195
 
190
 
Line 203... Line 198...
203
		}
198
		}
Line 204... Line 199...
204
		
199
		
Line 205... Line 200...
205
	}
200
	}
206
	
-
 
207
	protected function refreshToken($token) {
201
	
208
//		$verificationServiceURL = 'https://www.tela-botanica.org/service:annuaire:auth/identite';
202
	protected function refreshToken($token) {
209
		$service = "auth/identite?token=" . $token;
-
 
-
 
203
		$service = "auth/identite?token=" . $token;
210
		$verificationServiceURL = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], $service);
204
		$verificationServiceURL = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], $service);
211
//		$verificationServiceURL .= "?token=" . $token;
-
 
-
 
205
 
212
		$ch = curl_init();
206
		$ch = curl_init();
Line 213... Line 207...
213
//		$timeout = 5;
207
 
214
		$cookie = 'tb_auth='.$token;
208
		$cookie = $this->config['authentification']['cookieName'].'='.$token;
215
		
209
		
Line 223... Line 217...
223
//		curl_setopt($ch, CURLOPT_HTTPHEADER, [
217
//		curl_setopt($ch, CURLOPT_HTTPHEADER, [
224
//			'Cookie: ' . $cookie,
218
//			'Cookie: ' . $cookie,
225
//		]);
219
//		]);
226
		curl_setopt($ch, CURLOPT_COOKIE, $cookie);
220
		curl_setopt($ch, CURLOPT_COOKIE, $cookie);
227
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
221
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
228
//		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
-
 
-
 
222
 
229
		// équivalent de "-k"
223
		// équivalent de "-k"
230
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
224
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
231
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
225
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
232
		$response = curl_exec($ch);
226
		$response = curl_exec($ch);
Line 233... Line -...
233
		
-
 
234
//		if ($response === false) {
-
 
235
//			echo 'Erreur cURL : ' . curl_error($ch);
-
 
236
//		} else {
-
 
237
//			echo 'Réponse : ' . $response;
-
 
238
//		}
-
 
239
		
227
		
Line 240... Line 228...
240
		curl_close($ch);
228
		curl_close($ch);
241
 
229