]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: tfa: allow apply only on valid inputs
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 5 Apr 2019 08:31:41 +0000 (10:31 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 5 Apr 2019 08:35:50 +0000 (10:35 +0200)
only when the totp form and the challenge is valid, allow pressing the
apply button, default is disabled, as the 'user_tfa' data binding was
not used anywhere else replace it with something more fitting.

change allowBlank for the challenge

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
www/manager6/dc/TFAEdit.js

index 76ab8d06064b05eba52fcf3bc686b4f7d0a1a7df..cb39a9a8668a436f07c4c0ebd525a474d08a468f 100644 (file)
@@ -106,6 +106,7 @@ Ext.define('PVE.window.TFAEdit', {
            in_totp_tab: true,
            tfa_required: false,
            has_tfa: false,
+           valid: false,
            u2f_available: true
        },
        formulas: {
@@ -148,6 +149,15 @@ Ext.define('PVE.window.TFAEdit', {
                    me.updateQrCode();
                }
            },
+           'field': {
+               validitychange: function(field, valid) {
+                   var me = this;
+                   var viewModel = me.getViewModel();
+                   var form = me.lookup('totp_form');
+                   var challenge = me.lookup('challenge');
+                   viewModel.set('valid', form.isValid() && challenge.isValid());
+               }
+           },
            '#': {
                show: function() {
                    var me = this.getView();
@@ -394,6 +404,7 @@ Ext.define('PVE.window.TFAEdit', {
                            xtype: 'textfield',
                            fieldLabel: gettext('Verification Code'),
                            labelWidth: 120,
+                           allowBlank: false,
                            reference: 'challenge',
                            padding: '0 5',
                            emptyText: gettext('Scan QR code and enter TOTP auth. code to verify')
@@ -441,7 +452,7 @@ Ext.define('PVE.window.TFAEdit', {
            handler: 'applySettings',
            bind: {
                hidden: '{!in_totp_tab}',
-               disabled: '{!user_tfa}'
+               disabled: '{!valid}'
            }
        },
        {