Skip to content

Commit e7e6ae0

Browse files
committed
fixed log out bug where user would automatically log back in after 2 seconds
1 parent b2660f3 commit e7e6ae0

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

app/electron/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ ipcMain.on('delete_cookie', event => {
377377
ipcMain.on('github', event => {
378378
// your applications credentials
379379
const githubUrl = 'https://github.com/login/oauth/authorize?';
380+
// const githubUrl = 'http://localhost:5000/auth/github';
380381
const options = {
381382
client_id: process.env.GITHUB_ID,
382383
client_secret: process.env.GITHUB_SECRET,

app/src/components/login/SignIn.tsx

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,22 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
6666
const [invalidUser, setInvalidUser] = useState(false);
6767
const [invalidPass, setInvalidPass] = useState(false);
6868

69-
70-
// useEffect(() => {
71-
// const githubCookie = setInterval(() => {
72-
// window.api.setCookie();
73-
// window.api.getCookie(cookie => {
74-
// // if a cookie exists, set localstorage item with cookie data, clear interval, go back to '/' route to load app
75-
// if (cookie[0]) {
76-
// window.localStorage.setItem('ssid', cookie[0].value);
77-
// clearInterval(githubCookie);
78-
// props.history.push('/');
79-
// // if an item is already set in localstorage (guest option or normal login) clear interval needs to be run or else this will constantly run
80-
// } else if (window.localStorage.getItem('ssid')) {
81-
// clearInterval(githubCookie);
82-
// }
83-
// });
84-
// }, 2000);
85-
// }, []);
69+
useEffect(() => {
70+
const githubCookie = setInterval(() => {
71+
window.api.setCookie();
72+
window.api.getCookie(cookie => {
73+
// if a cookie exists, set localstorage item with cookie data, clear interval, go back to '/' route to load app
74+
if (cookie[0]) {
75+
window.localStorage.setItem('ssid', cookie[0].value);
76+
clearInterval(githubCookie);
77+
props.history.push('/');
78+
// if an item is already set in localstorage (guest option or normal login) clear interval needs to be run or else this will constantly run
79+
} else if (window.localStorage.getItem('ssid')) {
80+
clearInterval(githubCookie);
81+
}
82+
});
83+
}, 2000);
84+
}, []);
8685

8786
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
8887
let inputVal = e.target.value;

app/src/components/right/LoginButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default function LoginButton() {
1212
e.preventDefault();
1313
// clear local storage
1414
window.localStorage.clear();
15+
window.api.delCookie();
1516
// destroys cookie by backdating expiration time
1617
// document.cookie = 'ssid=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
1718
// destroy cookie in production via electron main process

0 commit comments

Comments
 (0)