mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 14:20:42 +08:00
Disable authentication in read-only mode
Tell the user how to enable experimental mode where authentication works.
This commit is contained in:
+7
-9
@@ -64,6 +64,9 @@ export async function authenticate(params: {
|
||||
signature: string;
|
||||
publicKey: string;
|
||||
}): Promise<boolean> {
|
||||
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 (
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user