summaryrefslogtreecommitdiffstats
path: root/apps/twofactor_backupcodes/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-01-09 23:11:19 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-01-15 20:45:42 +0100
commit09712320501a3e64541c429ca460c30eefced099 (patch)
tree2f3b60485f0ddba68a7bc89fde60fdf99f69f9a8 /apps/twofactor_backupcodes/lib
parent53c077afc9077dcadcaf4b8ad62590fb549947b0 (diff)
downloadnextcloud-server-09712320501a3e64541c429ca460c30eefced099.tar.gz
nextcloud-server-09712320501a3e64541c429ca460c30eefced099.zip
Provide initial state for backupcodes in template
This saves a direct request to the server when loading the backup codes. There is no need for this as the data is already known. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/twofactor_backupcodes/lib')
-rw-r--r--apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php3
-rw-r--r--apps/twofactor_backupcodes/lib/Settings/Personal.php12
2 files changed, 12 insertions, 3 deletions
diff --git a/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php b/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php
index 27653c1dd61..807371907db 100644
--- a/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php
+++ b/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php
@@ -148,7 +148,8 @@ class BackupCodesProvider implements IProvider, IProvidesPersonalSettings {
* @return IPersonalProviderSettings
*/
public function getPersonalSettings(IUser $user): IPersonalProviderSettings {
- return new Personal();
+ $state = $this->storage->getBackupCodesState($user);
+ return new Personal(base64_encode(json_encode($state)));
}
}
diff --git a/apps/twofactor_backupcodes/lib/Settings/Personal.php b/apps/twofactor_backupcodes/lib/Settings/Personal.php
index 0b71b1da088..426336e1a56 100644
--- a/apps/twofactor_backupcodes/lib/Settings/Personal.php
+++ b/apps/twofactor_backupcodes/lib/Settings/Personal.php
@@ -24,14 +24,22 @@ declare(strict_types=1);
namespace OCA\TwoFactorBackupCodes\Settings;
-
use OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings;
use OCP\Template;
class Personal implements IPersonalProviderSettings {
+ /** @var string */
+ private $state;
+
+ public function __construct(string $state) {
+ $this->state = $state;
+ }
+
public function getBody(): Template {
- return new Template('twofactor_backupcodes', 'personal');
+ $template = new Template('twofactor_backupcodes', 'personal');
+ $template->assign('state', $this->state);
+ return $template;
}
}