File tree Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 17
17
use Flarum \Api \Serializer \CurrentUserSerializer ;
18
18
use Flarum \Api \Serializer \ForumSerializer ;
19
19
use Flarum \Api \Serializer \GroupSerializer ;
20
- use Flarum \Console \Schedule ;
21
20
use Flarum \Extend ;
22
21
use Flarum \Group \Event \Saving as GroupSaving ;
23
22
use Flarum \Group \Group ;
24
23
use Flarum \User \User ;
25
24
use IanM \TwoFactor \Api \Serializer \TwoFactorSerializer ;
26
25
use IanM \TwoFactor \Model \TwoFactor ;
27
26
use IanM \TwoFactor \OAuth \TwoFactorOAuthCheck ;
28
- use Illuminate \Console \Scheduling \Event ;
29
27
30
28
return [
31
29
(new Extend \Frontend ('forum ' ))
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ /*
4
+ * This file is part of ianm/twofactor.
5
+ *
6
+ * Copyright (c) 2023 IanM.
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE.md
9
+ * file that was distributed with this source code.
10
+ */
11
+
3
12
namespace IanM \TwoFactor \Console ;
4
13
5
14
use Flarum \Settings \SettingsRepositoryInterface ;
@@ -9,14 +18,15 @@ class InactiveTokensSchedule
9
18
{
10
19
public function __construct (
11
20
protected SettingsRepositoryInterface $ settings
12
- ) { }
21
+ ) {
22
+ }
13
23
14
24
public function __invoke (Event $ event )
15
25
{
16
26
if (! (bool ) $ this ->settings ->get ('ianm-twofactor.kill_inactive_tokens ' )) {
17
27
return ;
18
28
}
19
-
29
+
20
30
$ event ->twiceDaily ();
21
31
}
22
32
}
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ /*
4
+ * This file is part of ianm/twofactor.
5
+ *
6
+ * Copyright (c) 2023 IanM.
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE.md
9
+ * file that was distributed with this source code.
10
+ */
11
+
3
12
namespace IanM \TwoFactor \Console ;
4
13
5
14
use Carbon \Carbon ;
@@ -22,7 +31,7 @@ public function handle(): void
22
31
{
23
32
$ age = (int ) $ this ->settings ->get ('ianm-twofactor.kill_inactive_tokens_age_days ' );
24
33
$ maxAge = Carbon::now ()->subdays ($ age );
25
-
34
+
26
35
$ query = AccessToken::query ()
27
36
->where ('last_activity_at ' , '< ' , $ maxAge );
28
37
@@ -35,6 +44,7 @@ public function handle(): void
35
44
36
45
if ($ count === 0 ) {
37
46
$ this ->info ("No tokens found which have not been used in $ age+ days. " );
47
+
38
48
return ;
39
49
}
40
50
You can’t perform that action at this time.
0 commit comments