From 7f9eef1d472bed7c56cc21ffdcedc24d98563d41 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 3 Mar 2021 13:59:58 +0100 Subject: [PATCH] ui: webauthn registration: adapt error messages There are variuos hints that 'InvalidStateError' can be assumed to come from an already registered token[0][1]. So indicate that more strongly, also omit the extra line and warning triangle, there's already an error icon present. [0]: step 2: https://w3c.github.io/webauthn/#sctn-registering-a-new-credential [1]: step 3: https://w3c.github.io/webauthn/#sctn-op-make-cred Signed-off-by: Thomas Lamprecht --- www/window/AddWebauthn.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/www/window/AddWebauthn.js b/www/window/AddWebauthn.js index f6d1df61..b89a9aa2 100644 --- a/www/window/AddWebauthn.js +++ b/www/window/AddWebauthn.js @@ -99,20 +99,12 @@ Ext.define('PBS.window.AddWebauthn', { try { token_response = await navigator.credentials.create(challenge_obj); } catch (error) { - let errmsg = ` - ${error.name}: ${error.message}`; + let errmsg = error.message; if (error.name === 'InvalidStateError') { - // probably a duplicate token - throw `${gettext('There was an error during authenticator registration.')} -
- ${gettext('This probably means that this authenticator is already registered.')} -

- ${errmsg}`; - } else { - throw `${gettext('There was an error during token registration.')} -

- ${errmsg}`; + errmsg = gettext('Is this token already registered?'); } + throw gettext('An error occurred during token registration.') + + `
${error.name}: ${errmsg}`; } // We cannot pass ArrayBuffers to the API, so extract & convert the data.