Clear account idb table on logout (#28996)

* Clear account idb table on logout

to remove old deactivated refresh token when logging out

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Simplify code

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Fix test

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2025-01-14 12:01:19 +00:00
committed by GitHub
parent 5882b004f5
commit 2559cba482
3 changed files with 47 additions and 36 deletions

View File

@@ -143,6 +143,11 @@ describe("Lifecycle", () => {
const table = mockStore[tableKey];
delete table?.[key as string];
});
jest.spyOn(StorageAccess, "idbClear")
.mockClear()
.mockImplementation(async (tableKey: string) => {
mockStore[tableKey] = {};
});
};
const homeserverUrl = "https://server.org";
@@ -613,7 +618,7 @@ describe("Lifecycle", () => {
it("should clear stores", async () => {
await setLoggedIn(credentials);
expect(StorageAccess.idbDelete).toHaveBeenCalledWith("account", "mx_access_token");
expect(StorageAccess.idbClear).toHaveBeenCalledWith("account");
expect(sessionStorage.clear).toHaveBeenCalled();
expect(mockClient.clearStores).toHaveBeenCalled();
});