Skip to content

Commit 307a894

Browse files
authored
Merge pull request #239 from ArcOS-Project/dev-izk-221-switchserver-token-clear
Clear credentials and persistence on server change
2 parents 9d31585 + 71ad55b commit 307a894

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/apps/core/switchserver/runtime.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { MessageBox } from "$ts/util/dialog";
55
import { Store } from "$ts/writable";
66
import type { App, AppProcessData } from "$types/app";
77
import type { ServerOption } from "$types/server";
8-
8+
import Cookies from "js-cookie";
99
export class SwitchServerRuntime extends AppProcess {
1010
servers = Store<ServerOption[]>([]);
1111
selected = Store<string>();
@@ -45,11 +45,22 @@ export class SwitchServerRuntime extends AppProcess {
4545
this.loading.set(true);
4646
this.connectionError.set(false);
4747

48+
const currentServer = Server.url;
49+
4850
const result = await Server.switchServer(server.url);
4951

5052
this.loading.set(false);
51-
if (!result) this.connectionError.set(true);
52-
else location.reload();
53+
if (!result) {
54+
this.connectionError.set(true);
55+
} else {
56+
if (currentServer !== server.url) {
57+
Cookies.remove("arcToken");
58+
Cookies.remove("arcUsername");
59+
localStorage.removeItem("arcLoginPersistence");
60+
}
61+
62+
location.reload();
63+
}
5364
}
5465

5566
async removeServer(server: ServerOption) {

0 commit comments

Comments
 (0)