diff --git a/app/assets/javascripts/discourse/app/components/modal/login.js b/app/assets/javascripts/discourse/app/components/modal/login.js index a8685290cb5..7b02ea0b2b4 100644 --- a/app/assets/javascripts/discourse/app/components/modal/login.js +++ b/app/assets/javascripts/discourse/app/components/modal/login.js @@ -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( diff --git a/app/assets/javascripts/discourse/app/components/modal/login/local-login-form.js b/app/assets/javascripts/discourse/app/components/modal/login/local-login-form.js index 728599ec43e..0fd555314ed 100644 --- a/app/assets/javascripts/discourse/app/components/modal/login/local-login-form.js +++ b/app/assets/javascripts/discourse/app/components/modal/login/local-login-form.js @@ -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