feat: Add logout option to client wipe functionality
- Add optional logout parameter to system.wipeClient - Add new 'Clear Local Storage & Logout' command - Update API to support logout parameter - Clean up server code comments
This commit is contained in:
@@ -99,7 +99,7 @@ export function systemSyscalls(
|
||||
}
|
||||
await client.loadCustomStyles();
|
||||
},
|
||||
"system.wipeClient": async () => {
|
||||
"system.wipeClient": async (_ctx, logout = false) => {
|
||||
// Two tracks:
|
||||
// 1. Service worker unregister
|
||||
// 2. IndexedDB cleaning
|
||||
@@ -157,7 +157,11 @@ export function systemSyscalls(
|
||||
}
|
||||
await client.ds.batchDelete(allKeys);
|
||||
}
|
||||
alert("Client wiped, feel free to navigate elsewhere");
|
||||
if (logout) {
|
||||
location.href = "/.logout";
|
||||
} else {
|
||||
alert("Client wiped, feel free to navigate elsewhere");
|
||||
}
|
||||
},
|
||||
// DEPRECATED
|
||||
"system.getEnv": () => {
|
||||
|
||||
@@ -75,6 +75,6 @@ export function getConfig<T = any>(
|
||||
return syscall("system.getConfig", key, defaultValue);
|
||||
}
|
||||
|
||||
export function wipeClient(): Promise<void> {
|
||||
return syscall("system.wipeClient");
|
||||
export function wipeClient(logout = false): Promise<void> {
|
||||
return syscall("system.wipeClient", logout);
|
||||
}
|
||||
|
||||
@@ -323,6 +323,11 @@ functions:
|
||||
command:
|
||||
name: "System: Wipe Client"
|
||||
|
||||
wipeAndLogoutCommand:
|
||||
path: ./system.ts:wipeAndLogoutCommand
|
||||
command:
|
||||
name: "Clear Local Storage & Logout"
|
||||
|
||||
versionCommand:
|
||||
path: ./help.ts:versionCommand
|
||||
command:
|
||||
|
||||
@@ -26,6 +26,10 @@ export async function wipeClientCommand() {
|
||||
await system.wipeClient();
|
||||
}
|
||||
|
||||
export async function wipeAndLogoutCommand() {
|
||||
await system.wipeClient(true);
|
||||
}
|
||||
|
||||
export async function reloadUICommand() {
|
||||
await editor.reloadUI();
|
||||
}
|
||||
|
||||
@@ -238,7 +238,6 @@ export class HttpServer {
|
||||
)
|
||||
: new LockoutTimer(0, 0); // disabled
|
||||
|
||||
// TODO: This should probably be a POST request
|
||||
this.app.get("/.logout", (c) => {
|
||||
const url = new URL(c.req.url);
|
||||
deleteCookie(c, authCookieName(url.host));
|
||||
|
||||
Reference in New Issue
Block a user