Subversion Repositories Applications.annuaire

Rev

Rev 579 | Rev 583 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 579 Rev 580
Line 11... Line 11...
11
		$url = "http://identify-test.plantnet-project.org/api/security/token/create?_username=$login&_password=$password";
11
		$url = "http://identify-test.plantnet-project.org/api/security/token/create?_username=$login&_password=$password";
Line 12... Line 12...
12
 
12
 
13
		$curl = curl_init();
13
		$curl = curl_init();
14
		curl_setopt($curl, CURLOPT_URL, $url);
14
		curl_setopt($curl, CURLOPT_URL, $url);
-
 
15
		curl_setopt($curl, CURLOPT_POST, true);
15
		curl_setopt($curl, CURLOPT_POST, true);
16
		curl_setopt($curl, CURLOPT_POSTFIELDS, array()); // nécessaire dans les versions modernes de libcurl sinon on se prend un 400 !
16
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);  
17
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
17
		$res = curl_exec($curl);
18
		$res = curl_exec($curl);
Line -... Line 19...
-
 
19
		curl_close($curl);
18
		curl_close($curl);
20
 
19
 
21
		//var_dump($res);
20
		$res = json_decode($res, true);
22
		$res = json_decode($res, true);
-
 
23
		//var_dump($res);
21
		//var_dump($res);
24
		if (!empty($res['JWT'])) {
22
		if (!empty($res['JWT'])) {
25
			$this->jetonPartenaire = $res['JWT'];
23
			$jeton = $this->lib->decoderJetonManuellement($res['JWT']);
26
			$jetonDecode = $this->auth->decoderJetonManuellement($this->jetonPartenaire);
24
			// stockage pour traitement dans les autres méthodes
27
			// stockage pour traitement dans les autres méthodes
25
			$this->data = $jeton;
28
			$this->data = $jetonDecode['details'];
26
			//var_dump($jeton);
29
			//var_dump($jeton);
27
			if (!empty($jeton['details']['email'])) {
30
			if ( !empty($this->data['email'])) {
28
				//var_dump($jeton['details']['email']);
31
				//var_dump($this->data['email']);
29
				return true;
32
				return true;
30
			}
-
 
31
		}
33
			}
32
 
34
		}
Line 33... Line 35...
33
		return false;
35
		return false;
34
	}
-
 
35
 
36
	}
36
	public function getIdentiteParCourriel() {
37
 
Line 37... Line 38...
37
 
38
	protected function getNomPartenaire() {
38
		echo "get identité par courriel<br/>";
-
 
39
	}
39
		return "plantnet";
40
 
40
	}
Line 41... Line 41...
41
	public function formaterNomWiki() {
41
 
-
 
42
	protected function getCourriel() {
-
 
43
		return $this->data['email'];
-
 
44
	}
Line 42... Line 45...
42
 
45
 
-
 
46
	protected function getId() {
-
 
47
		// la clef primaire est le "username" dans Pl@ntNet, apparemment
-
 
48
		return $this->data['username'];
-
 
49
	}
-
 
50
 
-
 
51
	protected function getValeursProfilPartenaire() {
43
		echo "formater nom wiki<br/>";
52
		return array(
-
 
53
			'nom' => $this->data['lastname'],
-
 
54
			'prenom' => $this->data['firstname'],
-
 
55
			'email' => $this->data['email'],
-
 
56
			'pseudo' => $this->data['username']
44
	}
57
		);