fix(Authorizer): Don't run login again if there is already a session based on basic auth

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
Marcel Klehr 2024-01-02 16:04:03 +01:00
parent 85ed3ed37c
commit 3d51a44fd0
1 changed files with 8 additions and 0 deletions

View File

@ -74,6 +74,10 @@ class Authorizer {
if (!$this->cors && $this->userSession->isLoggedIn()) {
$this->setUserId($this->userSession->getUser()->getUID());
} elseif (isset($request->server['PHP_AUTH_USER'], $request->server['PHP_AUTH_PW'])) {
if ($this->userSession->getUser() !== null) {
$this->setUserId($this->userSession->getUser()->getUID());
return;
}
if (false === $this->userSession->login($request->server['PHP_AUTH_USER'], $request->server['PHP_AUTH_PW'])) {
return;
}
@ -81,6 +85,10 @@ class Authorizer {
} elseif ($auth !== null && $auth !== '') {
[$type, $credentials] = explode(' ', $auth);
if (strtolower($type) === 'basic') {
if ($this->userSession->getUser() !== null) {
$this->setUserId($this->userSession->getUser()->getUID());
return;
}
[$username, $password] = explode(':', base64_decode($credentials));
if (false === $this->userSession->login($username, $password)) {
return;