From bc6097ab87d6cbb492e27a84dcd86243da4001c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 2 Nov 2020 14:55:08 +0100 Subject: [PATCH] Add IMultifactorMethod --- com.woltlab.wcf/objectType.xml | 2 +- com.woltlab.wcf/objectTypeDefinition.xml | 2 +- com.woltlab.wcf/templates/accountSecurity.tpl | 2 +- .../multifactor/IMultifactorMethod.class.php | 21 ++++++++++++++++++ .../TotpMultifactorMethod.class.php | 22 +++++++++++++++++++ 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 wcfsetup/install/files/lib/system/user/multifactor/IMultifactorMethod.class.php create mode 100644 wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 3ad90f1700..334c8d3e92 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -1725,7 +1725,7 @@ com.woltlab.wcf.multifactor.totp com.woltlab.wcf.multifactor mobile - + wcf\system\user\multifactor\TotpMultifactorMethod diff --git a/com.woltlab.wcf/objectTypeDefinition.xml b/com.woltlab.wcf/objectTypeDefinition.xml index aa476c34d9..35ea56d528 100644 --- a/com.woltlab.wcf/objectTypeDefinition.xml +++ b/com.woltlab.wcf/objectTypeDefinition.xml @@ -220,7 +220,7 @@ com.woltlab.wcf.multifactor - + wcf\system\user\multifactor\IMultifactorMethod diff --git a/com.woltlab.wcf/templates/accountSecurity.tpl b/com.woltlab.wcf/templates/accountSecurity.tpl index 12bc297d72..20a3954b47 100644 --- a/com.woltlab.wcf/templates/accountSecurity.tpl +++ b/com.woltlab.wcf/templates/accountSecurity.tpl @@ -16,7 +16,7 @@

{lang}wcf.user.security.multifactor.{$method->objectType}{/lang}

- {$method|var_dump} + {$method->getProcessor()->getStatusText($__wcf->user)}
diff --git a/wcfsetup/install/files/lib/system/user/multifactor/IMultifactorMethod.class.php b/wcfsetup/install/files/lib/system/user/multifactor/IMultifactorMethod.class.php new file mode 100644 index 0000000000..33ec715ccd --- /dev/null +++ b/wcfsetup/install/files/lib/system/user/multifactor/IMultifactorMethod.class.php @@ -0,0 +1,21 @@ + + * @package WoltLabSuite\System\User\Multifactor + * @since 5.4 + */ +interface IMultifactorMethod { + /** + * Returns a human readable status text regarding the set-up status for the given user. + * + * An example text could be: "5 backup codes remaining". + */ + public function getStatusText(User $user): string; +} diff --git a/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php b/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php new file mode 100644 index 0000000000..6c16f7f807 --- /dev/null +++ b/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php @@ -0,0 +1,22 @@ + + * @package WoltLabSuite\System\User\Multifactor + * @since 5.4 + */ +class TotpMultifactorMethod implements IMultifactorMethod { + /** + * Returns the number of devices the user set up. + */ + public function getStatusText(User $user): string { + // TODO: Return a proper text. + return random_int(10000, 99999)." devices configured"; + } +} -- 2.20.1