tfa: show 'Locked' in 'Enabled' column if tfa is locked

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2023-06-06 12:03:18 +02:00 committed by Thomas Lamprecht
parent 50af081a20
commit 33cfd1f6b4

View File

@ -67,8 +67,11 @@ Ext.define('Proxmox.panel.TfaView', {
onLoad: function(store, data, success) { onLoad: function(store, data, success) {
if (!success) return; if (!success) return;
let now = new Date().getTime() / 1000;
let records = []; let records = [];
Ext.Array.each(data, user => { 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 => { Ext.Array.each(user.data.entries, entry => {
records.push({ records.push({
fullid: `${user.id}/${entry.id}`, fullid: `${user.id}/${entry.id}`,
@ -77,6 +80,7 @@ Ext.define('Proxmox.panel.TfaView', {
description: entry.description, description: entry.description,
created: entry.created, created: entry.created,
enable: entry.enable, 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], renderUser: fullid => fullid.split('/')[0],
renderEnabled: enabled => { renderEnabled: function(enabled, metaData, record) {
if (enabled === undefined) { if (record.data.locked) {
return gettext("Locked");
} else if (enabled === undefined) {
return Proxmox.Utils.yesText; return Proxmox.Utils.yesText;
} else { } else {
return Proxmox.Utils.format_boolean(enabled); return Proxmox.Utils.format_boolean(enabled);