From 21788ae3ebe05c457ee8c08e1616d26505f48fcb Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 1 Oct 2024 12:20:20 +0200 Subject: [PATCH] fix(Auth): ignore missing token when trying to set password-unconfirmable Signed-off-by: Arthur Schiwon --- 3rdparty | 2 +- lib/private/legacy/OC_User.php | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/3rdparty b/3rdparty index 3558cc253049d..2f879893c5791 160000 --- a/3rdparty +++ b/3rdparty @@ -1 +1 @@ -Subproject commit 3558cc253049d15a89760af2ecfa8bcfac4f4802 +Subproject commit 2f879893c579124154f9b72d65f69a4d1c821adc diff --git a/lib/private/legacy/OC_User.php b/lib/private/legacy/OC_User.php index 8fdba3a62b2f5..4cc102d6672b4 100644 --- a/lib/private/legacy/OC_User.php +++ b/lib/private/legacy/OC_User.php @@ -7,6 +7,8 @@ */ use OC\Authentication\Token\IProvider; use OC\User\LoginException; +use OCP\Authentication\Exceptions\InvalidTokenException; +use OCP\Authentication\Exceptions\WipeTokenException; use OCP\Authentication\Token\IToken; use OCP\EventDispatcher\IEventDispatcher; use OCP\IGroupManager; @@ -14,6 +16,7 @@ use OCP\IUser; use OCP\IUserManager; use OCP\Server; +use OCP\Session\Exceptions\SessionNotAvailableException; use OCP\User\Events\BeforeUserLoggedInEvent; use OCP\User\Events\UserLoggedInEvent; use Psr\Log\LoggerInterface; @@ -171,12 +174,17 @@ public static function loginWithApache(\OCP\Authentication\IApacheBackend $backe if (empty($password)) { $tokenProvider = \OC::$server->get(IProvider::class); - $token = $tokenProvider->getToken($userSession->getSession()->getId()); - $token->setScope([ - IToken::SCOPE_SKIP_PASSWORD_VALIDATION => true, - IToken::SCOPE_FILESYSTEM => true, - ]); - $tokenProvider->updateToken($token); + try { + $token = $tokenProvider->getToken($userSession->getSession()->getId()); + $token->setScope([ + IToken::SCOPE_SKIP_PASSWORD_VALIDATION => true, + IToken::SCOPE_FILESYSTEM => true, + ]); + $tokenProvider->updateToken($token); + } catch (InvalidTokenException|WipeTokenException|SessionNotAvailableException) { + // swallow the exceptions as we do not deal with them here + // simply skip updating the token when is it missing + } } // setup the filesystem