ui: u2f: refactor error code map out and use in login window

to avoid showing numbers as error codes to users, even though the
strings are not much more helpful either...

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2019-04-10 09:48:13 +02:00
parent 35e8d081ec
commit 2d41c7e6f2
3 changed files with 13 additions and 9 deletions

View File

@ -808,6 +808,17 @@ Ext.define('PVE.Utils', { utilities: {
return Ext.htmlEncode(first + " " + last);
},
render_u2f_error: function(error) {
var ErrorNames = {
'1': gettext('Other Error'),
'2': gettext('Bad Request'),
'3': gettext('Configuration Unsupported'),
'4': gettext('Device Ineligible'),
'5': gettext('Timeout')
};
return "U2F Error: " + ErrorNames[error] || Proxmox.Utils.unknownText;
},
windowHostname: function() {
return window.location.hostname.replace(Proxmox.Utils.IP6_bracket_match,
function(m, addr, offset, original) { return addr; });

View File

@ -40,16 +40,9 @@ Ext.define('PVE.window.TFAEdit', {
},
showError: function(error) {
var ErrorNames = {
'1': gettext('Other Error'),
'2': gettext('Bad Request'),
'3': gettext('Configuration Unsupported'),
'4': gettext('Device Ineligible'),
'5': gettext('Timeout')
};
Ext.Msg.alert(
gettext('Error'),
"U2F Error: " + (ErrorNames[error] || Proxmox.Utils.unknownText)
PVE.Utils.render_u2f_error(error)
);
},

View File

@ -107,7 +107,7 @@ Ext.define('PVE.window.LoginWindow', {
msg.close();
if (res.errorCode) {
Proxmox.Utils.authClear();
Ext.Msg.alert(gettext('Error'), "U2F Error: "+res.errorCode);
Ext.Msg.alert(gettext('Error'), PVE.Utils.render_u2f_error(res.errorCode));
return;
}
delete res.errorCode;