1
0

TokenCleanupJob.php 661 B

12345678910111213141516171819202122232425
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-only
  5. */
  6. namespace OC\Authentication\Token;
  7. use OCP\AppFramework\Utility\ITimeFactory;
  8. use OCP\BackgroundJob\TimedJob;
  9. class TokenCleanupJob extends TimedJob {
  10. private IProvider $provider;
  11. public function __construct(ITimeFactory $time, IProvider $provider) {
  12. parent::__construct($time);
  13. $this->provider = $provider;
  14. // Run once a day at off-peak time
  15. $this->setInterval(24 * 60 * 60);
  16. $this->setTimeSensitivity(self::TIME_INSENSITIVE);
  17. }
  18. protected function run($argument) {
  19. $this->provider->invalidateOldTokens();
  20. }
  21. }