DEV: Improve error messaging (#24099)

Applies to passkeys, visible in a dev environment when using a non-standard
host. The error modal should only be shown when invoking the passkey
login button.
This commit is contained in:
Penar Musaraj 2023-10-25 13:44:08 -04:00 committed by GitHub
parent 334be4eac7
commit e231ed2153
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 4 deletions

View File

@ -146,15 +146,31 @@ export async function getPasskeyCredential(
userHandle: bufferToBase64(credential.response.userHandle),
};
} catch (error) {
if (error.name === "NotAllowedError") {
return errorCallback(I18n.t("login.security_key_not_allowed_error"));
} else if (error.name === "AbortError") {
if (error.name === "AbortError") {
// no need to show an error when the cancelling a pending ceremony
// this happens when switching from the conditional method (username input autofill)
// to the optional method (login button) or vice versa
return null;
}
if (mediation === "conditional") {
// The conditional method gets triggered in the background
// it's not helpful to show errors for it in the UI
// eslint-disable-next-line no-console
console.error(error);
return null;
}
if (error.name === "NotAllowedError") {
return errorCallback(I18n.t("login.security_key_not_allowed_error"));
} else if (error.name === "SecurityError") {
return errorCallback(
I18n.t("login.passkey_security_error", {
message: error.message,
})
);
} else {
return errorCallback(error);
return errorCallback(error.message);
}
}
}

View File

@ -2203,6 +2203,7 @@ en:
security_key_no_matching_credential_error: "No matching credentials could be found in the provided security key."
security_key_support_missing_error: "Your current device or browser does not support the use of security keys. Please use a different method."
security_key_invalid_response_error: "The security key authentication process failed due to an invalid response."
passkey_security_error: "There was a security error: %{message}"
email_placeholder: "Email / Username"
caps_lock_warning: "Caps Lock is on"
error: "Unknown error"