5,7 → 5,7 |
/** |
* Permet de se connecter à l'annuaire de Tela Botanica à l'aide d'un compte Pl@ntNet / identify |
*/ |
class AuthPartnerPlantnet extends AuthPartner { |
class AuthPartnerPlantnet extends AuthPartner { |
|
public function verifierAcces($login, $password) { |
$url = "http://identify-test.plantnet-project.org/api/security/token/create?_username=$login&_password=$password"; |
13,38 → 13,51 |
$curl = curl_init(); |
curl_setopt($curl, CURLOPT_URL, $url); |
curl_setopt($curl, CURLOPT_POST, true); |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
curl_setopt($curl, CURLOPT_POSTFIELDS, array()); // nécessaire dans les versions modernes de libcurl sinon on se prend un 400 ! |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
$res = curl_exec($curl); |
curl_close($curl); |
|
//var_dump($res); |
$res = json_decode($res, true); |
//var_dump($res); |
if (!empty($res['JWT'])) { |
$jeton = $this->lib->decoderJetonManuellement($res['JWT']); |
$this->jetonPartenaire = $res['JWT']; |
$jetonDecode = $this->auth->decoderJetonManuellement($this->jetonPartenaire); |
// stockage pour traitement dans les autres méthodes |
$this->data = $jeton; |
$this->data = $jetonDecode['details']; |
//var_dump($jeton); |
if (!empty($jeton['details']['email'])) { |
//var_dump($jeton['details']['email']); |
if ( !empty($this->data['email'])) { |
//var_dump($this->data['email']); |
return true; |
} |
} |
|
return false; |
} |
|
public function getIdentiteParCourriel() { |
protected function getNomPartenaire() { |
return "plantnet"; |
} |
|
echo "get identité par courriel<br/>"; |
protected function getCourriel() { |
return $this->data['email']; |
} |
|
public function formaterNomWiki() { |
protected function getId() { |
// la clef primaire est le "username" dans Pl@ntNet, apparemment |
return $this->data['username']; |
} |
|
echo "formater nom wiki<br/>"; |
protected function getValeursProfilPartenaire() { |
return array( |
'nom' => $this->data['lastname'], |
'prenom' => $this->data['firstname'], |
'email' => $this->data['email'], |
'pseudo' => $this->data['username'] |
); |
} |
|
public function getDateDerniereModifProfil() { |
|
echo "get date dernière modif profil<br/>"; |
} |
/*public function getTimestampMajPartenaire() { |
return 420000000000; |
}*/ |
} |