[pve-devel] [PATCH manager] ui: tfa: allow apply only on valid inputs
Dominik Csapak
d.csapak at proxmox.com
Fri Apr 5 10:31:41 CEST 2019
only when the totp form and the challenge is valid, allow pressing the
apply button, default is disabled
change allowBlank for the challenge
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/manager6/dc/TFAEdit.js | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/www/manager6/dc/TFAEdit.js b/www/manager6/dc/TFAEdit.js
index 76ab8d06..cb39a9a8 100644
--- a/www/manager6/dc/TFAEdit.js
+++ b/www/manager6/dc/TFAEdit.js
@@ -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}'
}
},
{
--
2.11.0
More information about the pve-devel
mailing list