From 71ad55b49e5ed3a308cfd37daf1fec6101be82b8 Mon Sep 17 00:00:00 2001 From: Izaak Kuipers Date: Sun, 1 Mar 2026 20:53:56 +0100 Subject: [PATCH] Clear credentials and persistence on server change --- src/apps/core/switchserver/runtime.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/apps/core/switchserver/runtime.ts b/src/apps/core/switchserver/runtime.ts index 469b4185..53218086 100644 --- a/src/apps/core/switchserver/runtime.ts +++ b/src/apps/core/switchserver/runtime.ts @@ -5,7 +5,7 @@ import { MessageBox } from "$ts/util/dialog"; import { Store } from "$ts/writable"; import type { App, AppProcessData } from "$types/app"; import type { ServerOption } from "$types/server"; - +import Cookies from "js-cookie"; export class SwitchServerRuntime extends AppProcess { servers = Store([]); selected = Store(); @@ -45,11 +45,22 @@ export class SwitchServerRuntime extends AppProcess { this.loading.set(true); this.connectionError.set(false); + const currentServer = Server.url; + const result = await Server.switchServer(server.url); this.loading.set(false); - if (!result) this.connectionError.set(true); - else location.reload(); + if (!result) { + this.connectionError.set(true); + } else { + if (currentServer !== server.url) { + Cookies.remove("arcToken"); + Cookies.remove("arcUsername"); + localStorage.removeItem("arcLoginPersistence"); + } + + location.reload(); + } } async removeServer(server: ServerOption) {