Skip to content

Commit

Permalink
fix(Auth): ignore missing token when trying to set password-unconfirm…
Browse files Browse the repository at this point in the history
…able

Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz authored and backportbot[bot] committed Oct 1, 2024
1 parent 0109d2f commit 4eb41b7
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/private/legacy/OC_User.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@
*/
use OC\Authentication\Token\IProvider;
use OC\User\LoginException;
use OCP\Authentication\Exceptions\InvalidTokenException;
use OCP\Authentication\Exceptions\WipeTokenException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\ILogger;
use OCP\ISession;
use OCP\IUserManager;
use OCP\Server;
use OCP\Session\Exceptions\SessionNotAvailableException;
use OCP\User\Events\BeforeUserLoggedInEvent;
use OCP\User\Events\UserLoggedInEvent;

Expand Down Expand Up @@ -198,12 +201,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([
'password-unconfirmable' => true,
'filesystem' => true,
]);
$tokenProvider->updateToken($token);
try {
$token = $tokenProvider->getToken($userSession->getSession()->getId());
$token->setScope([
'password-unconfirmable' => true,
'filesystem' => true,
]);
$tokenProvider->updateToken($token);
} catch (InvalidTokenException|WipeTokenException|SessionNotAvailableException) {

Check failure

Code scanning / Psalm

UndefinedClass Error

Class, interface or enum named OCP\Authentication\Exceptions\InvalidTokenException does not exist

Check failure

Code scanning / Psalm

UndefinedClass Error

Class, interface or enum named OCP\Authentication\Exceptions\WipeTokenException does not exist

Check failure on line 211 in lib/private/legacy/OC_User.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedClass

lib/private/legacy/OC_User.php:211:15: UndefinedClass: Class, interface or enum named OCP\Authentication\Exceptions\InvalidTokenException does not exist (see https://psalm.dev/019)

Check failure on line 211 in lib/private/legacy/OC_User.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedClass

lib/private/legacy/OC_User.php:211:37: UndefinedClass: Class, interface or enum named OCP\Authentication\Exceptions\WipeTokenException does not exist (see https://psalm.dev/019)
// swallow the exceptions as we do not deal with them here
// simply skip updating the token when is it missing
}
}

// setup the filesystem
Expand Down

0 comments on commit 4eb41b7

Please sign in to comment.