summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/twofactor_backupcodes/lib/BackgroundJob/CheckBackupCodes.php6
-rw-r--r--apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php6
-rw-r--r--apps/twofactor_backupcodes/lib/Db/BackupCodeMapper.php11
-rw-r--r--apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php2
4 files changed, 11 insertions, 14 deletions
diff --git a/apps/twofactor_backupcodes/lib/BackgroundJob/CheckBackupCodes.php b/apps/twofactor_backupcodes/lib/BackgroundJob/CheckBackupCodes.php
index 752e745b936..9a39ffdb79f 100644
--- a/apps/twofactor_backupcodes/lib/BackgroundJob/CheckBackupCodes.php
+++ b/apps/twofactor_backupcodes/lib/BackgroundJob/CheckBackupCodes.php
@@ -25,9 +25,10 @@ declare(strict_types=1);
namespace OCA\TwoFactorBackupCodes\BackgroundJob;
use OC\Authentication\TwoFactorAuth\Manager;
-use OC\BackgroundJob\QueuedJob;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Authentication\TwoFactorAuth\IRegistry;
use OCP\BackgroundJob\IJobList;
+use OCP\BackgroundJob\QueuedJob;
use OCP\IUser;
use OCP\IUserManager;
@@ -45,7 +46,8 @@ class CheckBackupCodes extends QueuedJob {
/** @var Manager */
private $twofactorManager;
- public function __construct(IUserManager $userManager, IJobList $jobList, Manager $twofactorManager, IRegistry $registry) {
+ public function __construct(ITimeFactory $timeFactory, IUserManager $userManager, IJobList $jobList, Manager $twofactorManager, IRegistry $registry) {
+ parent::__construct($timeFactory);
$this->userManager = $userManager;
$this->jobList = $jobList;
$this->twofactorManager = $twofactorManager;
diff --git a/apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php b/apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php
index 1f227061feb..b04a8c3a29f 100644
--- a/apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php
+++ b/apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php
@@ -24,10 +24,10 @@ declare(strict_types=1);
namespace OCA\TwoFactorBackupCodes\BackgroundJob;
-use OC\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Authentication\TwoFactorAuth\IRegistry;
use OCP\BackgroundJob\IJobList;
+use OCP\BackgroundJob\TimedJob;
use OCP\IUserManager;
use OCP\Notification\IManager;
@@ -39,9 +39,6 @@ class RememberBackupCodesJob extends TimedJob {
/** @var IUserManager */
private $userManager;
- /** @var ITimeFactory */
- private $time;
-
/** @var IManager */
private $notificationManager;
@@ -53,6 +50,7 @@ class RememberBackupCodesJob extends TimedJob {
ITimeFactory $timeFactory,
IManager $notificationManager,
IJobList $jobList) {
+ parent::__construct($timeFactory);
$this->registry = $registry;
$this->userManager = $userManager;
$this->time = $timeFactory;
diff --git a/apps/twofactor_backupcodes/lib/Db/BackupCodeMapper.php b/apps/twofactor_backupcodes/lib/Db/BackupCodeMapper.php
index 03fe7bb5ec8..20a1134cff3 100644
--- a/apps/twofactor_backupcodes/lib/Db/BackupCodeMapper.php
+++ b/apps/twofactor_backupcodes/lib/Db/BackupCodeMapper.php
@@ -22,11 +22,12 @@
namespace OCA\TwoFactorBackupCodes\Db;
use OCP\AppFramework\Db\Mapper;
+use OCP\AppFramework\Db\QBMapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\IUser;
-class BackupCodeMapper extends Mapper {
+class BackupCodeMapper extends QBMapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'twofactor_backupcodes');
@@ -43,14 +44,8 @@ class BackupCodeMapper extends Mapper {
$qb->select('id', 'user_id', 'code', 'used')
->from('twofactor_backupcodes')
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($user->getUID())));
- $result = $qb->execute();
- $rows = $result->fetchAll();
- $result->closeCursor();
-
- return array_map(function ($row) {
- return BackupCode::fromRow($row);
- }, $rows);
+ return self::findEntities($qb);
}
/**
diff --git a/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php b/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php
index ad1ce71545d..235414ffe75 100644
--- a/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php
+++ b/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php
@@ -27,6 +27,7 @@ namespace OCA\TwoFactorBackupCodes\Tests\Unit\BackgroundJob;
use OC\Authentication\TwoFactorAuth\Manager;
use OCA\TwoFactorBackupCodes\BackgroundJob\CheckBackupCodes;
use OCA\TwoFactorBackupCodes\BackgroundJob\RememberBackupCodesJob;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Authentication\TwoFactorAuth\IRegistry;
use OCP\BackgroundJob\IJobList;
use OCP\IUser;
@@ -70,6 +71,7 @@ class CheckBackupCodeTest extends TestCase {
}));
$this->checkBackupCodes = new CheckBackupCodes(
+ $this->createMock(ITimeFactory::class),
$this->userManager,
$this->jobList,
$this->manager,