Skip to content

Commit 4eb41b7

Browse files
blizzzbackportbot[bot]
authored andcommitted
fix(Auth): ignore missing token when trying to set password-unconfirmable
Signed-off-by: Arthur Schiwon <[email protected]>
1 parent 0109d2f commit 4eb41b7

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/private/legacy/OC_User.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@
3737
*/
3838
use OC\Authentication\Token\IProvider;
3939
use OC\User\LoginException;
40+
use OCP\Authentication\Exceptions\InvalidTokenException;
41+
use OCP\Authentication\Exceptions\WipeTokenException;
4042
use OCP\EventDispatcher\IEventDispatcher;
4143
use OCP\ILogger;
4244
use OCP\ISession;
4345
use OCP\IUserManager;
4446
use OCP\Server;
47+
use OCP\Session\Exceptions\SessionNotAvailableException;
4548
use OCP\User\Events\BeforeUserLoggedInEvent;
4649
use OCP\User\Events\UserLoggedInEvent;
4750

@@ -198,12 +201,17 @@ public static function loginWithApache(\OCP\Authentication\IApacheBackend $backe
198201

199202
if (empty($password)) {
200203
$tokenProvider = \OC::$server->get(IProvider::class);
201-
$token = $tokenProvider->getToken($userSession->getSession()->getId());
202-
$token->setScope([
203-
'password-unconfirmable' => true,
204-
'filesystem' => true,
205-
]);
206-
$tokenProvider->updateToken($token);
204+
try {
205+
$token = $tokenProvider->getToken($userSession->getSession()->getId());
206+
$token->setScope([
207+
'password-unconfirmable' => true,
208+
'filesystem' => true,
209+
]);
210+
$tokenProvider->updateToken($token);
211+
} catch (InvalidTokenException|WipeTokenException|SessionNotAvailableException) {
212+
// swallow the exceptions as we do not deal with them here
213+
// simply skip updating the token when is it missing
214+
}
207215
}
208216

209217
// setup the filesystem

0 commit comments

Comments
 (0)