Skip to content

Commit e33c17c

Browse files
committed
chore: Add more debug output
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent 71847ff commit e33c17c

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

lib/private/Authentication/Token/PublicKeyToken.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ public function getLoginName(): string {
128128
*/
129129
#[\Override]
130130
public function getPassword(): ?string {
131-
return parent::getPassword();
131+
$password = parent::getPassword();
132+
if ($password === '') {
133+
return null;
134+
}
135+
return $password;
132136
}
133137

134138
#[\Override]

lib/private/User/Session.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ private function checkTokenCredentials(IToken $dbToken, $token, array &$reason)
716716
$pwd = $this->tokenProvider->getPassword($dbToken, $token);
717717
} catch (InvalidTokenException $ex) {
718718
$reason = [
719-
'exception' => $ex,
719+
'additional_message' => $ex,
720720
];
721721

722722
// An invalid token password was used -> log user out
@@ -726,7 +726,7 @@ private function checkTokenCredentials(IToken $dbToken, $token, array &$reason)
726726
if (!is_null($this->activeUser) && !$this->activeUser->isEnabled()) {
727727
$reason = [
728728
'exception' => $ex,
729-
'message' => 'Paswordless token exception with no active or disabled user',
729+
'additional_message' => 'Passwordless token exception with no active or disabled user',
730730
];
731731
$this->tokenProvider->invalidateToken($token);
732732
return false;
@@ -739,7 +739,7 @@ private function checkTokenCredentials(IToken $dbToken, $token, array &$reason)
739739
if (!is_null($this->activeUser) && !$this->activeUser->isEnabled()) {
740740
$this->tokenProvider->invalidateToken($token);
741741
$reason = [
742-
'message' => 'Invalidate token as the user is no longer active',
742+
'additional_message' => 'Invalidate token as the user is no longer active',
743743
];
744744
return false;
745745
}
@@ -748,7 +748,7 @@ private function checkTokenCredentials(IToken $dbToken, $token, array &$reason)
748748
if ($this->manager->checkPassword($dbToken->getLoginName(), $pwd) === false) {
749749
$this->tokenProvider->markPasswordInvalid($dbToken, $token);
750750
$reason = [
751-
'message' => 'The token password is no longer valid',
751+
'additional_message' => 'The token password is no longer valid and is ' . (empty($pwd) ? 'empty' : 'not empty'),
752752
];
753753
// User is logged out
754754
return false;
@@ -787,10 +787,12 @@ private function validateToken(string $token, ?string $user = null): bool {
787787

788788
$reason = [];
789789
if (!$this->checkTokenCredentials($dbToken, $token, $reason)) {
790-
$this->logger->warning('Session token credentials are invalid', array_merge($reason, [
790+
$this->logger->warning('Session token credentials are invalid', [
791791
'app' => 'core',
792792
'user' => $user,
793-
]));
793+
'token name' => $dbToken->getName(),
794+
...$reason,
795+
]);
794796
return false;
795797
}
796798

0 commit comments

Comments
 (0)