Skip to content

Commit 3c38418

Browse files
authored
fix(Session): Prevent immediate token invalidation
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
1 parent 7d24904 commit 3c38418

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

lib/private/User/Session.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,10 +731,22 @@ private function checkTokenCredentials(IToken $dbToken, $token) {
731731
return false;
732732
}
733733

734-
// If the token password is no longer valid mark it as such
735734
if ($this->manager->checkPassword($dbToken->getLoginName(), $pwd) === false) {
735+
// If the decrypted password is empty or not a valid local password,
736+
// but the user exists and is enabled, we DO NOT permanently invalidate the token.
737+
// This prevents tokens generated via OCC or used in SSO environments
738+
// from being killed after 5 minutes
739+
if (empty($pwd) || $this->manager->get($dbToken->getLoginName()) !== null) {
740+
$this->logger->warning('Password check failed for user {user}, but user is active. Token preserved.', [
741+
'app' => 'core',
742+
'user' => $dbToken->getLoginName(),
743+
]);
744+
return false;
745+
}
746+
747+
// Legitimate password change or invalid user
748+
// Invalidate the token
736749
$this->tokenProvider->markPasswordInvalid($dbToken, $token);
737-
// User is logged out
738750
return false;
739751
}
740752

0 commit comments

Comments
 (0)