]> git.proxmox.com Git - pmg-gui.git/commitdiff
add Unlock TFA button
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 28 Jun 2023 07:53:28 +0000 (09:53 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 28 Jun 2023 07:56:24 +0000 (09:56 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
js/UserView.js

index a7c4415dc9bd0db5fac5f5d46c7416a7d4bac8be..c6b46737e19c88c7cafbfda67107eb9b5e0e6835 100644 (file)
@@ -84,6 +84,30 @@ Ext.define('PMG.UserView', {
            var view = this.getView();
            view.reload();
        },
+
+       onUnlockTfa: function(btn, event, rec) {
+           let me = this;
+           let view = me.getView();
+           Ext.Msg.confirm(
+               Ext.String.format(gettext('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: view,
+                           method: 'PUT',
+                           failure: function(response, options) {
+                               Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+                           },
+                           success: function(response, options) {
+                               view.reload();
+                           },
+                       });
+                   }
+               },
+           );
+       },
     },
 
     listeners: {
@@ -116,6 +140,14 @@ Ext.define('PMG.UserView', {
            disabled: true,
            handler: 'onPassword',
        },
+       '-',
+       {
+           xtype: 'proxmoxButton',
+           text: gettext('Unlock TFA'),
+           handler: 'onUnlockTfa',
+           enableFn: ({ data }) =>
+               data['totp-locked'] || (data['tfa-locked-until'] > (new Date().getTime() / 1000)),
+       },
     ],
 
     columns: [