Skip to content

Commit

Permalink
Clear electron data when logging out (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Mar 17, 2023
1 parent c560bb2 commit 18d80e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@sentry/electron": "^4.3.0",
"auto-launch": "^5.0.5",
"counterpart": "^0.18.6",
"electron-clear-data": "^1.0.5",
"electron-store": "^8.0.2",
"electron-window-state": "^5.0.3",
"minimist": "^1.2.6",
Expand Down
8 changes: 8 additions & 0 deletions src/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ limitations under the License.
*/

import { app, autoUpdater, desktopCapturer, ipcMain, powerSaveBlocker } from "electron";
import { relaunchApp } from "electron-clear-data";

import IpcMainEvent = Electron.IpcMainEvent;
import { recordSSOSession } from "./protocol";
Expand Down Expand Up @@ -186,6 +187,13 @@ ipcMain.on("ipcCall", async function (_ev: IpcMainEvent, payload) {
}));
break;

case "clearStorage":
global.store.clear();
global.mainWindow.webContents.session.flushStorageData();
await global.mainWindow.webContents.session.clearStorageData();
relaunchApp();
break;

default:
global.mainWindow.webContents.send("ipcReply", {
id: payload.id,
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4438,6 +4438,11 @@ electron-builder@^23.6.0:
simple-update-notifier "^1.0.7"
yargs "^17.5.1"

electron-clear-data@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/electron-clear-data/-/electron-clear-data-1.0.5.tgz#bc636f6850f57b1e8ed3fe2e57ca877e30d31bc9"
integrity sha512-vynYILZ2F+S5qnc81bnTOfh8uCVlxP6j42T7h/ELaDL+vxmlT1QNgte8KNuXb+s9ed+Qx4IIRbMRUcbAJa/8rA==

electron-devtools-installer@^3.1.1:
version "3.2.0"
resolved "https://registry.yarnpkg.com/electron-devtools-installer/-/electron-devtools-installer-3.2.0.tgz#acc48d24eb7033fe5af284a19667e73b78d406d0"
Expand Down

0 comments on commit 18d80e4

Please sign in to comment.