Skip to content

Commit c1f34e3

Browse files
committed
FIXED GITHUB OAUTH!
1 parent e7e6ae0 commit c1f34e3

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

app/electron/main.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,8 @@ ipcMain.on('delete_cookie', event => {
375375

376376
// opens new window for github oauth when button on sign in page is clicked
377377
ipcMain.on('github', event => {
378-
// your applications credentials
379-
const githubUrl = 'https://github.com/login/oauth/authorize?';
380-
// const githubUrl = 'http://localhost:5000/auth/github';
378+
console.log('inside main.js in electron');
379+
const githubURL = 'http://localhost:5000/auth/github';
381380
const options = {
382381
client_id: process.env.GITHUB_ID,
383382
client_secret: process.env.GITHUB_SECRET,
@@ -397,8 +396,8 @@ ipcMain.on('github', event => {
397396
zoomFactor: 1.0
398397
}
399398
});
400-
const authUrl = `${githubUrl}client_id=${process.env.GITHUB_ID}`;
401-
github.loadURL(authUrl);
399+
400+
github.loadURL(githubURL);
402401
github.show();
403402
const handleCallback = url => {
404403
const raw_code = /code=([^&]\*)/.exec(url) || null;
@@ -443,6 +442,9 @@ ipcMain.on('github', event => {
443442
if (isDev) {
444443
redirectUrl = 'http://localhost:8080/';
445444
}
445+
console.log(callbackUrl === redirectUrl);
446+
console.log('callbackUrl', callbackUrl);
447+
console.log('redirectUrl', redirectUrl);
446448
if (callbackUrl === redirectUrl) {
447449
dialog.showMessageBox({
448450
type: 'info',

app/src/components/login/SignIn.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
6868

6969
useEffect(() => {
7070
const githubCookie = setInterval(() => {
71-
window.api.setCookie();
72-
window.api.getCookie(cookie => {
71+
window.api?.setCookie();
72+
window.api?.getCookie(cookie => {
7373
// if a cookie exists, set localstorage item with cookie data, clear interval, go back to '/' route to load app
7474
if (cookie[0]) {
7575
window.localStorage.setItem('ssid', cookie[0].value);

app/src/components/right/LoginButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ export default function LoginButton() {
1212
e.preventDefault();
1313
// clear local storage
1414
window.localStorage.clear();
15+
// destroy cookie in production via electron main process
1516
window.api.delCookie();
1617
// destroys cookie by backdating expiration time
1718
// document.cookie = 'ssid=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
18-
// destroy cookie in production via electron main process
19-
// window.api.delCookie();
2019
// uses useHistory to return to the login page
2120
history.push('/login');
2221
};

0 commit comments

Comments
 (0)