Skip to content

Commit

Permalink
Actually resolved merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanger2000 committed Mar 29, 2023
1 parent 7dc7095 commit 5defeb7
Showing 1 changed file with 0 additions and 94 deletions.
94 changes: 0 additions & 94 deletions src/main/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,6 @@ export async function refreshTokens(event?: IpcMainInvokeEvent) {
// state: 'thisisatest',
}),
}
<<<<<<< HEAD
try {
const response = await fetch(
`https://${auth0Domain}/oauth/token`,
refreshOptions
)
const origData = await response.json()
const data = origData as {
access_token: string
id_token: string
}
=======
>>>>>>> main

const response = await fetch(
`https://${auth0Domain}/oauth/token`,
Expand Down Expand Up @@ -185,12 +172,7 @@ export async function loadStripeProfile() {
Authorization: `Bearer ${accessToken}`,
},
})
<<<<<<< HEAD
let resp = await response.json()
=======
const resp = await response.json()
console.log('GOT STRIPE PROFILE', resp)
>>>>>>> main
if (resp) {
stripeProfile = resp as string
}
Expand Down Expand Up @@ -226,61 +208,9 @@ export function getLogOutUrl() {
return `https://${auth0Domain}/v2/logout`
}

<<<<<<< HEAD
export async function login() {
// const { url, state, } = getAuthenticationURL()
await shell.openExternal(loginUrl);
=======
export function createAuthWindow(parentWindow: BrowserWindow) {
destroyAuthWin(parentWindow)

win = new BrowserWindow({
width: 1000,
height: 800,
modal: true,
show: true,
frame: true,
// parent: parentWindow,
webPreferences: {
nodeIntegration: false,
webSecurity: false,
// enableRemoteModule: false
},
})

const { url, verifier } = getAuthenticationURL()
console.log('SENDING TO URL', url)

const {
session: { webRequest },
} = win.webContents

const filter = {
urls: [DUMMY_URL],
}
const requestListener = async ({ url }: { url: string }) => {
console.log('INTERRUPTED', url)
await loadTokens(url, verifier, parentWindow)
await loadStripeProfile()
console.log('GOT STRIPE PROFILE', stripeProfile)
// Not sure what to do here:
// createAppWindow();
if (!stripeProfile && win) {
console.log('Creating stripe window')
createStripeWindow(parentWindow, win)
} else {
console.log('Destroying auth window')
return destroyAuthWin(parentWindow)
}
}

webRequest.onBeforeRequest(filter, requestListener)

win?.webContents.loadURL(url)
win.on('closed', () => {
win = null
})
>>>>>>> main
}

export async function signup() {
Expand Down Expand Up @@ -311,7 +241,6 @@ export function createLogoutWindow(event: IpcMainInvokeEvent) {
}

export function authPackage() {
<<<<<<< HEAD
// Simple browser opening functions
ipcMain.handle('loginCursor', login);
ipcMain.handle('signupCursor', signup)
Expand All @@ -329,29 +258,6 @@ export function authPackage() {
accessToken = data.accessToken
profile = data.profile
stripeProfile = data.stripeProfile
=======
ipcMain.handle('loginCursor', async (event: IpcMainInvokeEvent) => {
console.log('LOGGING IN CURSOR')
const mainWindow = BrowserWindow.fromWebContents(event.sender)
if (mainWindow) {
createAuthWindow(mainWindow)
} else {
console.log('main window not found')
}
})
ipcMain.handle('payCursor', async (event: IpcMainInvokeEvent) => {
console.log('PAYING CURSOR')
const mainWindow = BrowserWindow.fromWebContents(event.sender)
if (mainWindow) {
createStripeWindow(mainWindow)
} else {
console.log('main window not found')
}
})

ipcMain.handle('refreshTokens', async (event: IpcMainInvokeEvent) => {
console.log('REFRESHING TOKENS')
>>>>>>> main
await refreshTokens(event)
await loadStripeProfile()

Expand Down

0 comments on commit 5defeb7

Please sign in to comment.