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 <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-03-03 13:59:58 +01:00
parent a8a0132766
commit 7f9eef1d47

View File

@ -99,20 +99,12 @@ Ext.define('PBS.window.AddWebauthn', {
try {
token_response = await navigator.credentials.create(challenge_obj);
} catch (error) {
let errmsg = `<i class="fa fa-warning warning"></i>
${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.')}
<br>
${gettext('This probably means that this authenticator is already registered.')}
<br><br>
${errmsg}`;
} else {
throw `${gettext('There was an error during token registration.')}
<br><br>
${errmsg}`;
errmsg = gettext('Is this token already registered?');
}
throw gettext('An error occurred during token registration.') +
`<br>${error.name}: ${errmsg}`;
}
// We cannot pass ArrayBuffers to the API, so extract & convert the data.