]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: u2f: refactor error code map out and use in login window
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 10 Apr 2019 07:48:13 +0000 (09:48 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 10 Apr 2019 07:49:13 +0000 (09:49 +0200)
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>
www/manager6/Utils.js
www/manager6/dc/TFAEdit.js
www/manager6/window/LoginWindow.js

index ffa6970a8002d61cf1ee459ea8262d80b2be5e7e..2d056d3cd3d13779bf909d60869f0bbf979c37a0 100644 (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; });
index a3dbfa1dd5b1699c1e0f8fdc13b375c80ed88291..f0f4e5f4293b29e586ed1c590477117520d5fc60 100644 (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)
        );
     },
 
index c6baad8a18197a93c80ee1874db5eb03a02421aa..65fe14cbaaf17c76ba9b22f951f5dab22957b510 100644 (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;