[pbs-devel] [PATCH backup 2/2] gui: enumerate recovery keys and list in 2nd factor window

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Jan 18 12:46:47 CET 2021


Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
 www/LoginView.js             | 20 +++++++++++++++++---
 www/window/AddTfaRecovery.js |  7 ++++++-
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/www/LoginView.js b/www/LoginView.js
index fa8772b5..2dd84de9 100644
--- a/www/LoginView.js
+++ b/www/LoginView.js
@@ -281,9 +281,9 @@ Ext.define('PBS.login.TfaWindow', {
 		me.lookup('totpButton').setVisible(false);
 	    }
 
-	    if (!view.challenge.recovery) {
+	    if (!view.challenge.recovery || !view.challenge.recovery.length) {
 		me.lookup('recoveryButton').setVisible(false);
-	    } else if (view.challenge.recovery === "low") {
+	    } else if (view.challenge.recovery.length <= 3) {
 		me.lookup('recoveryButton')
 		    .setIconCls('fa fa-fw fa-exclamation-triangle');
 	    }
@@ -384,7 +384,12 @@ Ext.define('PBS.login.TfaWindow', {
 		me.lookup('webauthnButton').setVisible(false);
 		me.lookup('recoveryButton').setText(gettext("Confirm"));
 		me.lookup('recoveryInfo').setVisible(true);
-		if (view.challenge.recovery === "low") {
+		console.log("RECOVERY:", view.challenge.recovery);
+		me.lookup('availableRecovery').update(Ext.String.htmlEncode(
+		    gettext('Available recovery keys: ') + view.challenge.recovery.join(', ')
+		));
+		me.lookup('availableRecovery').setVisible(true);
+		if (view.challenge.recovery.length <= 3) {
 		    me.lookup('recoveryLow').setVisible(true);
 		}
 	    }
@@ -456,6 +461,15 @@ Ext.define('PBS.login.TfaWindow', {
 		textAlign: "center",
 	    },
 	},
+	{
+	    xtype: 'box',
+	    padding: '0 5',
+	    reference: 'availableRecovery',
+	    hidden: true,
+	    style: {
+		textAlign: "center",
+	    },
+	},
 	{
 	    xtype: 'box',
 	    padding: '0 5',
diff --git a/www/window/AddTfaRecovery.js b/www/window/AddTfaRecovery.js
index b63e8576..1718f026 100644
--- a/www/window/AddTfaRecovery.js
+++ b/www/window/AddTfaRecovery.js
@@ -24,7 +24,12 @@ Ext.define('PBS.window.AddTfaRecovery', {
 	    return;
 	}
 
-	let values = response.result.data.recovery.join("\n");
+	let values = response
+	    .result
+	    .data
+	    .recovery
+	    .map((v, i) => `${i}: ${v}`)
+	    .join("\n");
 	Ext.create('PBS.window.TfaRecoveryShow', {
 	    autoShow: true,
 	    userid: this.getViewModel().get('userid'),
-- 
2.20.1






More information about the pbs-devel mailing list