Skip to content

Commit

Permalink
Merge pull request #48492 from nextcloud/backport/48484/stable30
Browse files Browse the repository at this point in the history
[stable30] fix(Auth): ignore missing token when trying to set password-unconfirm…
  • Loading branch information
blizzz authored Oct 1, 2024
2 parents 8e093bd + f794ad0 commit b501c80
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 @@ -7,13 +7,16 @@
*/
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;
use OCP\ISession;
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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b501c80

Please sign in to comment.