diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-03-05 20:21:37 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-03-05 20:21:37 +0100 |
commit | 3d17ab0936c74c1a60360e06bb99fb7ce3cdc161 (patch) | |
tree | b87e19ddda189e65d752b29711eb97d27e510698 /apps/twofactor_backupcodes/lib | |
parent | 1c29a01956f13348281d29f276c8c37c85ed93e3 (diff) | |
download | nextcloud-server-3d17ab0936c74c1a60360e06bb99fb7ce3cdc161.tar.gz nextcloud-server-3d17ab0936c74c1a60360e06bb99fb7ce3cdc161.zip |
Do not send notification if no active 2fa
If the job is still present we should also not fire it off if there is
not a single active 2FA provider.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/twofactor_backupcodes/lib')
-rw-r--r-- | apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php b/apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php index b04a8c3a29f..1a7f5aca3eb 100644 --- a/apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php +++ b/apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php @@ -70,7 +70,15 @@ class RememberBackupCodesJob extends TimedJob { } $providers = $this->registry->getProviderStates($user); - if (isset($providers['backup_codes']) && $providers['backup_codes'] === true) { + $state2fa = array_reduce($providers, function(bool $carry, bool $state) { + return $carry || $state; + }, false); + + /* + * If no provider is active or if the backup codes are already generate + * we can remove the job + */ + if ($state2fa === false || (isset($providers['backup_codes']) && $providers['backup_codes'] === true)) { // Backup codes already generated lets remove this job $this->jobList->remove(self::class, $argument); return; |