diff --git a/authjwt.php b/authjwt.php index e21873e..9b7553b 100644 --- a/authjwt.php +++ b/authjwt.php @@ -45,6 +45,8 @@ class authjwt extends auth // }}} /** Try to authenticate the email/password of the user + * If the token is valid, return all the data available in payload. Can + * return a value without email attribute ! * @param string $email Email not used (wait for Bearer) * @param string $password Password not used (wait for Bearer) */ @@ -64,11 +66,17 @@ class authjwt extends auth $this->payload = (array)$payload; $this->payload["bearer"] = substr ($_SERVER["HTTP_AUTHENTICATION"], 7); } - if (! key_exists ("email", $this->payload)) + else + { + $this->payload = array ("lastname" => "anonymous", + "firstname" => "", + "email" => "anonymous"); throw new \Exception ("No email available in Bearer", 403); + } } - /** Return all the parameters recorded for the authenticate user */ + /** Return all the parameters recorded for the authenticate user + */ public function getdetails () { if ($this->payload["email"] === "anonymous")