Skip to content

Commit 01c8f09

Browse files
authored
Simplify secure context check (#33906)
As discussed in https://github.com/go-gitea/gitea/pull/33820/files#r1997532169.
1 parent 5266311 commit 01c8f09

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

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

+4-7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@ export async function initUserAuthWebAuthn() {
1111
return;
1212
}
1313

14-
if (window.location.protocol === 'http:') {
15-
// webauthn is only supported on secure contexts
16-
const isLocalhost = ['localhost', '127.0.0.1'].includes(window.location.hostname);
17-
if (!isLocalhost) {
18-
hideElem(elSignInPasskeyBtn);
19-
return;
20-
}
14+
// webauthn is only supported on secure contexts
15+
if (!window.isSecureContext) {
16+
hideElem(elSignInPasskeyBtn);
17+
return;
2118
}
2219

2320
if (!detectWebAuthnSupport()) {

0 commit comments

Comments
 (0)