[pve-devel] [PATCH v2 widget-toolkit] tfa: improve UX for recovery keys and when none are left
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed May 17 15:22:14 CEST 2023
On Wed, May 17, 2023 at 01:59:28PM +0200, Wolfgang Bumiller wrote:
> If we get an empty challenge, tell the user to contact an
> administrator as it means no 2nd factors and no recovery
> keys are available.
>
> Currently if only 1 key was available and it had a high ID,
> we'd show something like: "Recovery keys available: 9,
> Warning, less than 4 keys available."
> Let's start off with the warning, and then be explicit about
> the IDs.
>
> Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
> ---
> Changes to v1 address Dominik's remarks:
> - Fix typos
> - Make generated ID list format string right-to-left compatible
> - Replace the pair of `hasAny2nd` and `hasNonRecovery2nd` with a
> counter and a `hasRecovery` boolean which allows expressing the
> condition that "either no 2nd factors, or only an already used up set of
> recovery keys exists" with less cognitive overhead.
>
> src/window/TfaWindow.js | 74 ++++++++++++++++++++++++++++++++---------
> 1 file changed, 58 insertions(+), 16 deletions(-)
>
> diff --git a/src/window/TfaWindow.js b/src/window/TfaWindow.js
> index 22ac50d..a622ce1 100644
> --- a/src/window/TfaWindow.js
> +++ b/src/window/TfaWindow.js
> @@ -45,11 +45,17 @@ Ext.define('Proxmox.window.TfaLoginWindow', {
>
> let lastTabId = me.getLastTabUsed();
> let initialTab = -1, i = 0;
> + let count2nd = 0;
> + let hasRecovery = false;
> for (const k of ['webauthn', 'totp', 'recovery', 'u2f', 'yubico']) {
> const available = !!challenge[k];
> vm.set(`availableChallenge.${k}`, available);
>
> if (available) {
> + count2nd++;
> + if (k !== 'recovery') {
^ Dominik noted that is a typo btw., needs to be `===`.
More information about the pve-devel
mailing list