diff --git a/src/lib/httpd.ts b/src/lib/httpd.ts index 2e63671d1..1e70dd376 100644 --- a/src/lib/httpd.ts +++ b/src/lib/httpd.ts @@ -64,6 +64,9 @@ export async function authenticate(params: { signature: string; publicKey: string; }): Promise { + if (!get(experimental)) { + return false; + } stateMutex.cancel(); return stateMutex.runExclusive(async () => { try { @@ -150,15 +153,6 @@ async function checkState() { scope: config?.scope, }; - // Return quickly and avoid additional fetches - // if experimental settings aren't updated - if (!get(experimental)) { - update({ - state: "running", - node, - }); - } - if (httpdState && httpdState.state !== "stopped") { httpdState.node = node; } @@ -216,6 +210,10 @@ function pollSession() { } export async function initialize() { + if (!get(experimental)) { + return; + } + // Sync session state changes with other open tabs and windows. addEventListener("storage", event => { if ( diff --git a/src/views/session/Index.svelte b/src/views/session/Index.svelte index 1dbeb30ad..114b76897 100644 --- a/src/views/session/Index.svelte +++ b/src/views/session/Index.svelte @@ -3,14 +3,16 @@ import { onMount } from "svelte"; + import * as httpd from "@app/lib/httpd"; import * as modal from "@app/lib/modal"; import * as router from "@app/lib/router"; - import * as httpd from "@app/lib/httpd"; + import { experimental } from "@app/lib/appearance"; import AppLayout from "@app/App/AppLayout.svelte"; import Loading from "@app/components/Loading.svelte"; import AuthenticationErrorModal from "@app/modals/AuthenticationErrorModal.svelte"; + import ErrorModal from "@app/modals/ErrorModal.svelte"; export let activeRoute: SessionRoute; @@ -21,12 +23,28 @@ } const isAuthenticated = await httpd.authenticate(activeRoute.params); - if (!isAuthenticated) { + if (!isAuthenticated && !$experimental) { + modal.show({ + component: ErrorModal, + props: { + title: "Authentication failed", + subtitle: [ + "Authentication only works in experimental mode.", + "Go to Settings, set experimental mode to On and try again.", + ], + error: { + message: "Can't authenticate in read-only mode.", + stack: undefined, + }, + }, + }); + } else if (!isAuthenticated) { modal.show({ component: AuthenticationErrorModal, props: {}, }); } + void router.navigateToUrl( "push", new URL(activeRoute.params.path || "", window.location.origin),