FIX: Only check for conditional mediation when needed (#24142)
Some browsers still don't support conditional mediation. This PR fixes issues with: - TOR browser (it doesn't have `PublicKeyCredential` at all) - Firefox 119 (doesn't support conditional mediation) We also need to make sure not to call `isConditionalMediationAvailable` on browsers that don't support the method but support the feature (like Safari on iOS).
This commit is contained in:
parent
73589fa475
commit
e7ed18fdfc
|
@ -19,6 +19,7 @@ import escape from "discourse-common/lib/escape";
|
|||
import I18n from "discourse-i18n";
|
||||
|
||||
export default class Login extends Component {
|
||||
@service capabilities;
|
||||
@service dialog;
|
||||
@service siteSettings;
|
||||
@service site;
|
||||
|
@ -116,6 +117,22 @@ export default class Login extends Component {
|
|||
@action
|
||||
async passkeyLogin(mediation = "optional") {
|
||||
try {
|
||||
// we need to check isConditionalMediationAvailable for Firefox
|
||||
// without it, Firefox will throw console errors
|
||||
// We cannot do a general check because iOS Safari and Chrome in Selenium quietly support the feature
|
||||
// but they do not support the PublicKeyCredential.isConditionalMediationAvailable() method
|
||||
if (
|
||||
mediation === "conditional" &&
|
||||
this.capabilities.isFirefox &&
|
||||
window.PublicKeyCredential
|
||||
) {
|
||||
const isCMA =
|
||||
// eslint-disable-next-line no-undef
|
||||
await PublicKeyCredential.isConditionalMediationAvailable();
|
||||
if (!isCMA) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const response = await ajax("/session/passkey/challenge.json");
|
||||
|
||||
const publicKeyCredential = await getPasskeyCredential(
|
||||
|
|
|
@ -36,15 +36,9 @@ export default class LocalLoginBody extends Component {
|
|||
|
||||
@action
|
||||
passkeyConditionalLogin() {
|
||||
if (
|
||||
// eslint-disable-next-line no-undef
|
||||
!PublicKeyCredential.isConditionalMediationAvailable ||
|
||||
!this.args.canUsePasskeys
|
||||
) {
|
||||
return;
|
||||
if (this.args.canUsePasskeys) {
|
||||
this.args.passkeyLogin("conditional");
|
||||
}
|
||||
|
||||
this.args.passkeyLogin("conditional");
|
||||
}
|
||||
|
||||
@action
|
||||
|
|
Loading…
Reference in New Issue