From f2f7a5f0c601470b0150d8e4ddef5dc4451255f9 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Sun, 8 Dec 2019 19:26:55 +0000 Subject: [PATCH] authjwt : return all the token instead of just email git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5808 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- authjwt.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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")