authentication : bad $auth usage

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5821 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2019-12-09 14:17:47 +00:00
parent 47b3179f1d
commit 6b64eb453e

View File

@@ -125,6 +125,18 @@ class authentication
if ($this->route->debug)
echo "<tt>Unset the JSON Web Token '$tokenName'</tt><br/>\n";
echo "<script>localStorage.removeItem('$tokenName');</script>\n";
$algorithm = "HS256";
$cipherKey = null;
$cacheDir = "data/jwtCache";
$authjwt = new authjwt ();
$authjwt->serverKey = $this->authServers["authjwt"]["serverKey"];
if (isset ($this->authServers["authjwt"]["cipherKey"]))
$authjwt->cipherKey = $this->authServers["authjwt"]["cipherKey"];
if (isset ($this->authServers["authjwt"]["algorithm"]))
$authjwt->algorithm = $this->authServers["authjwt"]["algorithm"];
if (isset ($this->authServers["authjwt"]["cacheDir"]))
$authjwt->cacheDir = $this->authServers["authjwt"]["cacheDir"];
$authjwt->logout ();
}
if ($this->debug) echo "Redirect to authentication page";
if ($this->debug) $this->route->debug = $this->debug;
@@ -312,9 +324,9 @@ class authentication
if (isset ($this->authServers["authjwt"]["cacheDir"]))
$cacheDir = $this->authServers["authjwt"]["cacheDir"];
$payloadArray = array();
$payloadArray["email"] = $payload;
if (is_array ($payload))
$payloadArray = $payload;
$payloadArray["email"] = $auth;
if (is_array ($auth))
$payloadArray = $auth;
if (! key_exists ("email", $payloadArray) ||
$payloadArray["email"] === "anonymous")
throw new \Exception ("JWT Must authenticate", 401);