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 committed Oct 1, 2024
1 parent 0109d2f commit 966bb30
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/private/legacy/OC_User.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Exceptions\WipeTokenException;
use OC\Authentication\Token\IProvider;
use OC\User\LoginException;
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 +202,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) {
// 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 966bb30

Please sign in to comment.