ui: tfa: specify which confirmation password is required

Clarify that the password of the user one wants to add TFA too is
required, which is not necessarily the one of the current logged in
user. Use an empty text for that.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-01-18 10:12:21 +01:00
parent b2a43b987c
commit 3189d05134
3 changed files with 49 additions and 9 deletions

View File

@ -34,6 +34,13 @@ Ext.define('PBS.window.AddTfaRecovery', {
viewModel: { viewModel: {
data: { data: {
has_entry: false, has_entry: false,
userid: Proxmox.UserName,
},
formulas: {
passwordConfirmText: (get) => {
let id = get('userid');
return Ext.String.format(gettext("Confirm password of '{0}'"), id);
},
}, },
}, },
@ -60,11 +67,13 @@ Ext.define('PBS.window.AddTfaRecovery', {
onUseridChange: async function(field, userid) { onUseridChange: async function(field, userid) {
let me = this; let me = this;
let vm = me.getViewModel();
me.userid = userid; me.userid = userid;
vm.set('userid', userid);
let has_entry = await me.hasEntry(userid); let has_entry = await me.hasEntry(userid);
me.getViewModel().set('has_entry', has_entry); vm.set('has_entry', has_entry);
}, },
}, },
@ -114,7 +123,9 @@ Ext.define('PBS.window.AddTfaRecovery', {
validateBlank: true, validateBlank: true,
hidden: Proxmox.UserName === 'root@pam', hidden: Proxmox.UserName === 'root@pam',
disabled: Proxmox.UserName === 'root@pam', disabled: Proxmox.UserName === 'root@pam',
emptyText: gettext('verify current password'), bind: {
emptyText: '{passwordConfirmText}',
},
}, },
], ],
}); });

View File

@ -47,12 +47,17 @@ Ext.define('PBS.window.AddTotp', {
valid: false, valid: false,
secret: '', secret: '',
otpuri: '', otpuri: '',
userid: Proxmox.UserName,
}, },
formulas: { formulas: {
secretEmpty: function(get) { secretEmpty: function(get) {
return get('secret').length === 0; return get('secret').length === 0;
}, },
passwordConfirmText: (get) => {
let id = get('userid');
return Ext.String.format(gettext("Confirm password of '{0}'"), id);
},
}, },
}, },
@ -140,11 +145,18 @@ Ext.define('PBS.window.AddTotp', {
}, },
renderer: Ext.String.htmlEncode, renderer: Ext.String.htmlEncode,
value: Proxmox.UserName, value: Proxmox.UserName,
listeners: {
change: function(field, newValue, oldValue) {
let vm = this.up('window').getViewModel();
vm.set('userid', newValue);
},
},
qrupdate: true, qrupdate: true,
}, },
{ {
xtype: 'textfield', xtype: 'textfield',
fieldLabel: gettext('Description'), fieldLabel: gettext('Description'),
emptyText: gettext('For example: TFA device ID, required to identify multiple factors.'),
allowBlank: false, allowBlank: false,
name: 'description', name: 'description',
maxLength: 256, maxLength: 256,
@ -225,7 +237,7 @@ Ext.define('PBS.window.AddTotp', {
}, },
{ {
xtype: 'textfield', xtype: 'textfield',
fieldLabel: gettext('Verification Code'), fieldLabel: gettext('Verify Code'),
allowBlank: false, allowBlank: false,
reference: 'challenge', reference: 'challenge',
name: 'challenge', name: 'challenge',
@ -233,18 +245,20 @@ Ext.define('PBS.window.AddTotp', {
disabled: '{!showTOTPVerifiction}', disabled: '{!showTOTPVerifiction}',
visible: '{showTOTPVerifiction}', visible: '{showTOTPVerifiction}',
}, },
emptyText: gettext('Scan QR code and enter TOTP auth. code to verify'), emptyText: gettext('Scan QR code in a TOTP app and enter an auth. code here'),
}, },
{ {
xtype: 'textfield', xtype: 'textfield',
inputType: 'password', inputType: 'password',
fieldLabel: gettext('Password'), fieldLabel: gettext('Verify Password'),
minLength: 5, minLength: 5,
reference: 'password', reference: 'password',
name: 'password', name: 'password',
allowBlank: false, allowBlank: false,
validateBlank: true, validateBlank: true,
emptyText: gettext('verify current password'), bind: {
emptyText: '{passwordConfirmText}',
},
}, },
], ],
}, },

View File

@ -22,6 +22,13 @@ Ext.define('PBS.window.AddWebauthn', {
viewModel: { viewModel: {
data: { data: {
valid: false, valid: false,
userid: Proxmox.UserName,
},
formulas: {
passwordConfirmText: (get) => {
let id = get('userid');
return Ext.String.format(gettext("Confirm password of '{0}'"), id);
},
}, },
}, },
@ -154,6 +161,12 @@ Ext.define('PBS.window.AddWebauthn', {
}, },
renderer: Ext.String.htmlEncode, renderer: Ext.String.htmlEncode,
value: Proxmox.UserName, value: Proxmox.UserName,
listeners: {
change: function(field, newValue, oldValue) {
let vm = this.up('window').getViewModel();
vm.set('userid', newValue);
},
},
}, },
{ {
xtype: 'textfield', xtype: 'textfield',
@ -161,18 +174,20 @@ Ext.define('PBS.window.AddWebauthn', {
allowBlank: false, allowBlank: false,
name: 'description', name: 'description',
maxLength: 256, maxLength: 256,
emptyText: gettext('a short distinguishing description'), emptyText: gettext('For example: TFA device ID, required to identify multiple factors.'),
}, },
{ {
xtype: 'textfield', xtype: 'textfield',
inputType: 'password', inputType: 'password',
fieldLabel: gettext('Password'), fieldLabel: gettext('Verify Password'),
minLength: 5, minLength: 5,
reference: 'password', reference: 'password',
name: 'password', name: 'password',
allowBlank: false, allowBlank: false,
validateBlank: true, validateBlank: true,
emptyText: gettext('verify current password'), bind: {
emptyText: '{passwordConfirmText}',
},
}, },
], ],
}, },