]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
improve error handling when adding webauthn entries
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 30 Nov 2021 10:04:03 +0000 (11:04 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 2 Dec 2021 18:19:31 +0000 (19:19 +0100)
There are cases where we directly throw a string error
(particularly, when navigator.credentials.create() fails,
for example when trying to register the same WA device to
the same user twice), which would end up with the WA window
simply not closing before.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/window/AddWebauthn.js

index f4a0b10fe7fcad4485ca7742008c4e656b6d31db..bef13d1dcc58cfe035baaf0c460f2fc51d516ce4 100644 (file)
@@ -141,8 +141,13 @@ Ext.define('Proxmox.window.AddWebauthn', {
                    params,
                });
            } catch (response) {
-               let error = response.result.message;
+               let error = response;
                console.error(error); // for debugging if it's not displayable...
+               if (typeof error === "object") {
+                   // in case it came from an api request:
+                   error = error.result?.message;
+               }
+
                Ext.Msg.alert(gettext('Error'), error);
            }