diff --git a/authjwt.php b/authjwt.php index 115c3ef..b9a851a 100644 --- a/authjwt.php +++ b/authjwt.php @@ -64,9 +64,11 @@ class authjwt extends auth // {{{ { if (! isset ($_SERVER["HTTP_AUTHENTICATION"])) - throw new \Exception ("No Authentication available", 401); + throw new \Exception (dgettext ("domframework", + "No Authentication available"), 401); if (substr ($_SERVER["HTTP_AUTHENTICATION"], 0, 7) !== "Bearer ") - throw new \Exception ("No Bearer Authentication available", 401); + throw new \Exception (dgettext ("domframework", + "No Bearer Authentication available"), 401); $token = substr ($_SERVER["HTTP_AUTHENTICATION"], 7); $jwt = new jwt (); $uuid = $jwt->decode ($token, $this->serverKey, $this->allowedAlg, @@ -111,10 +113,11 @@ class authjwt extends auth if ($this->serverKey === null) return ""; if (! key_exists ("email", $auth)) - throw new \Exception ("AuthJWT : No email available in auth", 403); + throw new \Exception (dgettext ("domframework", + "AuthJWT : No email available in auth"), 403); if ($auth["email"] === "anonymous") - throw new \Exception ("AuthJWT : can not create token for anonymous", - 403); + throw new \Exception (dgettext ("domframework", + "AuthJWT : can not create token for anonymous"), 403); $uuid = uuid::uuid4 (); $cachefile = new cachefile (); $cachefile->directory = $this->cacheDir; @@ -158,9 +161,11 @@ class authjwt extends auth // {{{ { if (! isset ($_SERVER["HTTP_AUTHENTICATION"])) - throw new \Exception ("No Authentication available", 401); + throw new \Exception (dgettext ("domframework", + "No Authentication available"), 401); if (substr ($_SERVER["HTTP_AUTHENTICATION"], 0, 7) !== "Bearer ") - throw new \Exception ("No Bearer Authentication available", 401); + throw new \Exception (dgettext ("domframework", + "No Bearer Authentication available"), 401); $token = substr ($_SERVER["HTTP_AUTHENTICATION"], 7); $jwt = new jwt (); $uuid = $jwt->decode ($token, $this->serverKey, $this->allowedAlg, @@ -169,7 +174,8 @@ class authjwt extends auth $cachefile->directory = $this->cacheDir; $payload = $cachefile->read ((string)$uuid); if (empty ($uuid) || empty ($payload) || ! key_exists ("email", $payload)) - throw new \Exception ("Can not found the token : no logout", 403); + throw new \Exception (dgettext ("domframework", + "Can not found the token : no logout"), 403); $cachefile->delete ($uuid); return true; }