public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 2/2] ui: user view: add 'Unlock TFA' button
Date: Tue,  6 Jun 2023 12:05:05 +0200	[thread overview]
Message-ID: <20230606100505.114456-2-w.bumiller@proxmox.com> (raw)
In-Reply-To: <20230606100505.114456-1-w.bumiller@proxmox.com>

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
 www/manager6/dc/UserView.js | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/www/manager6/dc/UserView.js b/www/manager6/dc/UserView.js
index e46ed13e..fec45deb 100644
--- a/www/manager6/dc/UserView.js
+++ b/www/manager6/dc/UserView.js
@@ -93,6 +93,35 @@ Ext.define('PVE.dc.UserView', {
 	    },
 	});
 
+	let unlock_btn = new Proxmox.button.Button({
+	    text: gettext('Unlock TFA'),
+	    disabled: true,
+	    selModel: sm,
+	    enableFn: rec => !!(caps.access['User.Modify'] &&
+	        (rec.data['totp-locked'] || rec.data['tfa-locked-until'])),
+	    handler: function(btn, event, rec) {
+		Ext.Msg.confirm(
+		    gettext(Ext.String.format('Unlock TFA authentication for {0}', rec.data.userid)),
+		    gettext("Locked 2nd factors can happen if the user's password was leaked. Are you sure you want to unlock the user?"),
+		    function(btn_response) {
+			if (btn_response === 'yes') {
+			    Proxmox.Utils.API2Request({
+				url: `/access/users/${rec.data.userid}/unlock-tfa`,
+				waitMsgTarget: me,
+				method: 'PUT',
+				failure: function(response, options) {
+				    Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+				},
+				success: function(response, options) {
+				    reload();
+				},
+			    });
+			}
+		    },
+		);
+	    },
+	});
+
 	Ext.apply(me, {
 	    store: store,
 	    selModel: sm,
@@ -116,6 +145,8 @@ Ext.define('PVE.dc.UserView', {
 		pwchange_btn,
 		'-',
 		perm_btn,
+		'-',
+		unlock_btn,
 	    ],
 	    viewConfig: {
 		trackOver: false,
-- 
2.39.2





  reply	other threads:[~2023-06-06 10:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06 10:05 [pve-devel] [PATCH manager 1/2] ui: user view: show tfa lock status Wolfgang Bumiller
2023-06-06 10:05 ` Wolfgang Bumiller [this message]
2023-06-07 16:08   ` [pve-devel] applied: [PATCH manager 2/2] ui: user view: add 'Unlock TFA' button Thomas Lamprecht
2023-06-07 16:08 ` [pve-devel] applied: [PATCH manager 1/2] ui: user view: show tfa lock status Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230606100505.114456-2-w.bumiller@proxmox.com \
    --to=w.bumiller@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal