Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Jun 15, 2024
1 parent c5c001a commit 83c8072
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 0 additions & 2 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
use Flarum\Api\Serializer\CurrentUserSerializer;
use Flarum\Api\Serializer\ForumSerializer;
use Flarum\Api\Serializer\GroupSerializer;
use Flarum\Console\Schedule;
use Flarum\Extend;
use Flarum\Group\Event\Saving as GroupSaving;
use Flarum\Group\Group;
use Flarum\User\User;
use IanM\TwoFactor\Api\Serializer\TwoFactorSerializer;
use IanM\TwoFactor\Model\TwoFactor;
use IanM\TwoFactor\OAuth\TwoFactorOAuthCheck;
use Illuminate\Console\Scheduling\Event;

return [
(new Extend\Frontend('forum'))
Expand Down
14 changes: 12 additions & 2 deletions src/Console/InactiveTokensSchedule.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of ianm/twofactor.
*
* Copyright (c) 2023 IanM.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace IanM\TwoFactor\Console;

use Flarum\Settings\SettingsRepositoryInterface;
Expand All @@ -9,14 +18,15 @@ class InactiveTokensSchedule
{
public function __construct(
protected SettingsRepositoryInterface $settings
) { }
) {
}

public function __invoke(Event $event)
{
if (! (bool) $this->settings->get('ianm-twofactor.kill_inactive_tokens')) {
return;
}

$event->twiceDaily();
}
}
12 changes: 11 additions & 1 deletion src/Console/KillInactiveTokensCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of ianm/twofactor.
*
* Copyright (c) 2023 IanM.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace IanM\TwoFactor\Console;

use Carbon\Carbon;
Expand All @@ -22,7 +31,7 @@ public function handle(): void
{
$age = (int) $this->settings->get('ianm-twofactor.kill_inactive_tokens_age_days');
$maxAge = Carbon::now()->subdays($age);

Check failure on line 33 in src/Console/KillInactiveTokensCommand.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.2

Call to an undefined method Carbon\Carbon::subdays().

Check failure on line 33 in src/Console/KillInactiveTokensCommand.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.3

Call to an undefined method Carbon\Carbon::subdays().

$query = AccessToken::query()
->where('last_activity_at', '<', $maxAge);

Expand All @@ -35,6 +44,7 @@ public function handle(): void

if ($count === 0) {
$this->info("No tokens found which have not been used in $age+ days.");

return;
}

Expand Down

0 comments on commit 83c8072

Please sign in to comment.