Skip to content

Commit 8a17e46

Browse files
authored
Merge pull request #371 from manosim/oauth-new-session
Clear the BrowserWindow session on login
2 parents bdc555f + b3a9721 commit 8a17e46

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

src/js/__mocks__/electron.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ const browserWindow = {
3131
loadURL: jest.fn(),
3232
webContents: {
3333
on: () => {},
34+
session: {
35+
clearStorageData: jest.fn(),
36+
},
3437
},
3538
on: () => {},
3639
close: jest.fn(),

src/js/utils/helpers.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ describe('utils/helpers.ts', () => {
105105

106106
authGithub(undefined, dispatch);
107107

108+
expect(
109+
new BrowserWindow().webContents.session.clearStorageData
110+
).toHaveBeenCalledTimes(1);
111+
108112
expect(new BrowserWindow().loadURL).toHaveBeenCalledTimes(1);
109113
expect(new BrowserWindow().loadURL).toHaveBeenCalledWith(
110114
'https://github.com/login/oauth/authorize?client_id=3fef4433a29c6ad8f22c&scope=user:email,notifications'
@@ -127,6 +131,10 @@ describe('utils/helpers.ts', () => {
127131
}
128132
);
129133

134+
expect(
135+
new BrowserWindow().webContents.session.clearStorageData
136+
).toHaveBeenCalledTimes(1);
137+
130138
// @ts-ignore
131139
new BrowserWindow().loadURL.mockReset();
132140

src/js/utils/helpers.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export function authGithub(
5353
const githubUrl = `https://${authOptions.hostname}/login/oauth/authorize`;
5454
const authUrl = `${githubUrl}?client_id=${authOptions.clientId}&scope=${Constants.AUTH_SCOPE}`;
5555

56+
const session = authWindow.webContents.session;
57+
session.clearStorageData();
58+
5659
authWindow.loadURL(authUrl);
5760

5861
function handleCallback(url) {

0 commit comments

Comments
 (0)