Skip to content

Commit 7f7a3cd

Browse files
authored
Merge pull request #48484 from nextcloud/fwdport/48445/master
fix(Auth): ignore missing token when trying to set password-unconfirm…
2 parents b30ef38 + 12d39e8 commit 7f7a3cd

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

lib/private/legacy/OC_User.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
*/
88
use OC\Authentication\Token\IProvider;
99
use OC\User\LoginException;
10+
use OCP\Authentication\Exceptions\InvalidTokenException;
11+
use OCP\Authentication\Exceptions\WipeTokenException;
1012
use OCP\Authentication\Token\IToken;
1113
use OCP\EventDispatcher\IEventDispatcher;
1214
use OCP\IGroupManager;
1315
use OCP\ISession;
1416
use OCP\IUser;
1517
use OCP\IUserManager;
1618
use OCP\Server;
19+
use OCP\Session\Exceptions\SessionNotAvailableException;
1720
use OCP\User\Events\BeforeUserLoggedInEvent;
1821
use OCP\User\Events\UserLoggedInEvent;
1922
use Psr\Log\LoggerInterface;
@@ -171,12 +174,17 @@ public static function loginWithApache(\OCP\Authentication\IApacheBackend $backe
171174

172175
if (empty($password)) {
173176
$tokenProvider = \OC::$server->get(IProvider::class);
174-
$token = $tokenProvider->getToken($userSession->getSession()->getId());
175-
$token->setScope([
176-
IToken::SCOPE_SKIP_PASSWORD_VALIDATION => true,
177-
IToken::SCOPE_FILESYSTEM => true,
178-
]);
179-
$tokenProvider->updateToken($token);
177+
try {
178+
$token = $tokenProvider->getToken($userSession->getSession()->getId());
179+
$token->setScope([
180+
IToken::SCOPE_SKIP_PASSWORD_VALIDATION => true,
181+
IToken::SCOPE_FILESYSTEM => true,
182+
]);
183+
$tokenProvider->updateToken($token);
184+
} catch (InvalidTokenException|WipeTokenException|SessionNotAvailableException) {
185+
// swallow the exceptions as we do not deal with them here
186+
// simply skip updating the token when is it missing
187+
}
180188
}
181189

182190
// setup the filesystem

0 commit comments

Comments
 (0)