1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) 2018, Roeland Jago Douma <[email protected]> |
5
|
|
|
* |
6
|
|
|
* @author Roeland Jago Douma <[email protected]> |
7
|
|
|
* |
8
|
|
|
* @license GNU AGPL version 3 or any later version |
9
|
|
|
* |
10
|
|
|
* This program is free software: you can redistribute it and/or modify |
11
|
|
|
* it under the terms of the GNU Affero General Public License as |
12
|
|
|
* published by the Free Software Foundation, either version 3 of the |
13
|
|
|
* License, or (at your option) any later version. |
14
|
|
|
* |
15
|
|
|
* This program is distributed in the hope that it will be useful, |
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
|
|
|
* GNU Affero General Public License for more details. |
19
|
|
|
* |
20
|
|
|
* You should have received a copy of the GNU Affero General Public License |
21
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace OCA\TwoFactorBackupCodes\BackgroundJob; |
26
|
|
|
|
27
|
|
|
use OC\Authentication\TwoFactorAuth\Manager; |
28
|
|
|
use OC\BackgroundJob\QueuedJob; |
29
|
|
|
use OCP\Authentication\TwoFactorAuth\IRegistry; |
30
|
|
|
use OCP\BackgroundJob\IJobList; |
31
|
|
|
use OCP\IUser; |
32
|
|
|
use OCP\IUserManager; |
33
|
|
|
|
34
|
|
|
class CheckBackupCodes extends QueuedJob { |
35
|
|
|
|
36
|
|
|
/** @var IUserManager */ |
37
|
|
|
private $userManager; |
38
|
|
|
|
39
|
|
|
/** @var IJobList */ |
40
|
|
|
private $jobList; |
41
|
|
|
|
42
|
|
|
/** @var Manager */ |
43
|
|
|
private $registry; |
44
|
|
|
|
45
|
|
|
/** @var Manager */ |
46
|
|
|
private $twofactorManager; |
47
|
|
|
|
48
|
|
|
public function __construct(IUserManager $userManager, IJobList $jobList, Manager $twofactorManager, IRegistry $registry) { |
49
|
|
|
$this->userManager = $userManager; |
50
|
|
|
$this->jobList = $jobList; |
51
|
|
|
$this->twofactorManager = $twofactorManager; |
52
|
|
|
$this->registry = $registry; |
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
protected function run($argument) { |
56
|
|
|
$this->userManager->callForSeenUsers(function(IUser $user) { |
57
|
|
|
$providers = $this->registry->getProviderStates($user); |
|
|
|
|
58
|
|
|
$isTwoFactorAuthenticated = $this->twofactorManager->isTwoFactorAuthenticated($user); |
59
|
|
|
|
60
|
|
|
if ($isTwoFactorAuthenticated && isset($providers['backup_codes']) && $providers['backup_codes'] === false) { |
61
|
|
|
$this->jobList->add(RememberBackupCodesJob::class, ['uid' => $user->getUID()]); |
62
|
|
|
} |
63
|
|
|
}); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..