From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 20DC09A50A for ; Wed, 17 May 2023 15:22:46 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 033C42819E for ; Wed, 17 May 2023 15:22:16 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 17 May 2023 15:22:14 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id ABCCF45529 for ; Wed, 17 May 2023 15:22:14 +0200 (CEST) Date: Wed, 17 May 2023 15:22:14 +0200 From: Wolfgang Bumiller To: pve-devel@lists.proxmox.com Message-ID: <4eev32dw7t4qze64mygtsdwraow4sozurj45corl4scnbw7t5b@excv4sxqczvc> References: <20230517115928.235012-1-w.bumiller@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230517115928.235012-1-w.bumiller@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.132 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pve-devel] [PATCH v2 widget-toolkit] tfa: improve UX for recovery keys and when none are left X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 May 2023 13:22:46 -0000 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 > --- > 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 `===`.