]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: tfa: also do not allow to delete TFA if not set
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 4 Apr 2019 07:17:54 +0000 (09:17 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 4 Apr 2019 07:18:00 +0000 (09:18 +0200)
better UX

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
www/manager6/dc/TFAEdit.js

index 78e9a42bea96c2f625696c7a6839b3bdbf3f75fe..653250827023579187b394d9a9e8b10e188ededa 100644 (file)
@@ -104,7 +104,13 @@ Ext.define('PVE.window.TFAEdit', {
        data: {
            in_totp_tab: true,
            tfa_required: false,
+           has_tfa: false,
            u2f_available: true
+       },
+       formulas: {
+           canDeleteTFA: function(get) {
+               return (get('has_tfa') && !get('tfa_required'));
+           }
        }
     },
 
@@ -144,7 +150,11 @@ Ext.define('PVE.window.TFAEdit', {
            '#': {
                show: function() {
                    var me = this.getView();
+                   var viewmodel = this.getViewModel();
+
                    me.down('#qrbox').getEl().appendChild(me.qrdiv);
+
+                   viewmodel.set('has_tfa', me.hasTFA);
                    if (!me.hasTFA) {
                        this.randomizeSecret();
                    } else {
@@ -440,7 +450,7 @@ Ext.define('PVE.window.TFAEdit', {
            reference: 'delete_button',
            handler: 'deleteTFA',
            bind: {
-               disabled: '{tfa_required}'
+               disabled: '{!canDeleteTFA}'
            }
        }
     ],