mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
@@ -146,15 +146,31 @@ export async function getPasskeyCredential(
|
|||||||
userHandle: bufferToBase64(credential.response.userHandle),
|
userHandle: bufferToBase64(credential.response.userHandle),
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.name === "NotAllowedError") {
|
if (error.name === "AbortError") {
|
||||||
return errorCallback(I18n.t("login.security_key_not_allowed_error"));
|
|
||||||
} else if (error.name === "AbortError") {
|
|
||||||
// no need to show an error when the cancelling a pending ceremony
|
// no need to show an error when the cancelling a pending ceremony
|
||||||
// this happens when switching from the conditional method (username input autofill)
|
// this happens when switching from the conditional method (username input autofill)
|
||||||
// to the optional method (login button) or vice versa
|
// to the optional method (login button) or vice versa
|
||||||
return null;
|
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 {
|
} else {
|
||||||
return errorCallback(error);
|
return errorCallback(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2203,6 +2203,7 @@ en:
|
|||||||
security_key_no_matching_credential_error: "No matching credentials could be found in the provided security key."
|
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_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."
|
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"
|
email_placeholder: "Email / Username"
|
||||||
caps_lock_warning: "Caps Lock is on"
|
caps_lock_warning: "Caps Lock is on"
|
||||||
error: "Unknown error"
|
error: "Unknown error"
|
||||||
|
|||||||
Reference in New Issue
Block a user