Simplify secure context check (#33906)

As discussed in
https://github.com/go-gitea/gitea/pull/33820/files#r1997532169.
pull/33905/head^2
silverwind 2025-03-16 12:05:26 +01:00 committed by GitHub
parent 52663113d4
commit 01c8f092a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 7 deletions

View File

@ -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()) {