Browse Source

Simplify secure context check (#33906)

As discussed in
https://github.com/go-gitea/gitea/pull/33820/files#r1997532169.
pull/33907/head
silverwind 9 months ago committed by GitHub
parent
commit
01c8f092a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      web_src/js/features/user-auth-webauthn.ts

11
web_src/js/features/user-auth-webauthn.ts

@ -11,13 +11,10 @@ export async function initUserAuthWebAuthn() { @@ -11,13 +11,10 @@ export async function initUserAuthWebAuthn() {
return;
}
if (window.location.protocol === 'http:') {
// webauthn is only supported on secure contexts
const isLocalhost = ['localhost', '127.0.0.1'].includes(window.location.hostname);
if (!isLocalhost) {
hideElem(elSignInPasskeyBtn);
return;
}
// webauthn is only supported on secure contexts
if (!window.isSecureContext) {
hideElem(elSignInPasskeyBtn);
return;
}
if (!detectWebAuthnSupport()) {

Loading…
Cancel
Save