[pve-devel] [PATCH widget-toolkit 2/2] tfa: show 'Locked' in 'Enabled' column if tfa is locked

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Jun 6 12:03:18 CEST 2023


Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
This one's new.

 src/panel/TfaView.js | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/panel/TfaView.js b/src/panel/TfaView.js
index e7a09a9..58b8a3a 100644
--- a/src/panel/TfaView.js
+++ b/src/panel/TfaView.js
@@ -67,8 +67,11 @@ Ext.define('Proxmox.panel.TfaView', {
 	onLoad: function(store, data, success) {
 	    if (!success) return;
 
+	    let now = new Date().getTime() / 1000;
 	    let records = [];
 	    Ext.Array.each(data, user => {
+		let tfa_locked = (user.data['tfa-locked-until'] || 0) > now;
+		let totp_locked = user.data['totp-locked'];
 		Ext.Array.each(user.data.entries, entry => {
 		    records.push({
 			fullid: `${user.id}/${entry.id}`,
@@ -77,6 +80,7 @@ Ext.define('Proxmox.panel.TfaView', {
 			description: entry.description,
 			created: entry.created,
 			enable: entry.enable,
+			locked: tfa_locked || (entry.type === 'totp' && totp_locked),
 		    });
 		});
 	    });
@@ -154,8 +158,10 @@ Ext.define('Proxmox.panel.TfaView', {
 
 	renderUser: fullid => fullid.split('/')[0],
 
-	renderEnabled: enabled => {
-	    if (enabled === undefined) {
+	renderEnabled: function(enabled, metaData, record) {
+	    if (record.data.locked) {
+		return gettext("Locked");
+	    } else if (enabled === undefined) {
 		return Proxmox.Utils.yesText;
 	    } else {
 		return Proxmox.Utils.format_boolean(enabled);
-- 
2.39.2






More information about the pve-devel mailing list