Skip to content

Commit

Permalink
Changes to get this fully working with 0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanger2000 committed Mar 30, 2023
1 parent bfd7f8d commit d5e1798
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/components/settingsPane.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useAppDispatch, useAppSelector } from '../app/hooks'

import { Switch} from '@headlessui/react'
import {HOMEPAGE_ROOT} from '../utils'

import * as ssel from '../features/settings/settingsSelectors'
import {
Expand Down Expand Up @@ -312,7 +313,7 @@ export function CursorLogin({showSettings = true}: {showSettings?: boolean}) {
dispatch(upgradeCursor(null))
}, [])
const openAccountSettings = useCallback(() => {
window.open('https://cursor.so/settings', '_blank')
window.open(`${HOMEPAGE_ROOT}/settings`, '_blank')
}, [])

let currentPanel
Expand Down
1 change: 1 addition & 0 deletions src/features/tools/toolSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export const toolSlice = createSlice({
stripeProfile?: string | null
}>
) {
console.log('Triggered with', action.payload)
if (action.payload.accessToken) {
state.cursorLogin.accessToken = action.payload.accessToken
} else if (action.payload.accessToken === null) {
Expand Down
24 changes: 12 additions & 12 deletions src/main/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
IpcMainInvokeEvent,
webContents,
} from 'electron'
import { API_ROOT } from '../utils'
import { API_ROOT, HOMEPAGE_ROOT } from '../utils'
import crypto from 'crypto'
import fetch from 'node-fetch'

Expand All @@ -17,14 +17,12 @@ const store = new Store()

let win: BrowserWindow | null = null

// const auth0Domain = 'cursor.us.auth0.com'
// const clientId = 'KbZUR41cY7W6zRSdpSUJ7I7mLYBKOCmB'
// const cursorHome = 'https://cursor.so'
const auth0Domain = 'cursor.us.auth0.com'
const clientId = 'KbZUR41cY7W6zRSdpSUJ7I7mLYBKOCmB'

// Test domain/client
const auth0Domain = 'dev-27d5cph2nbetfllb.us.auth0.com'
const clientId = 'OzaBXLClY5CAGxNzUhQ2vlknpi07tGuE'
const cursorHome = 'http://localhost:4000'
// const auth0Domain = 'dev-27d5cph2nbetfllb.us.auth0.com'
// const clientId = 'OzaBXLClY5CAGxNzUhQ2vlknpi07tGuE'

let accessToken: string | null = null
let profile: any | null = null
Expand All @@ -42,10 +40,10 @@ const DUMMY_URL = `${API_ROOT}/dummy/*`
const API_AUDIENCE = `https://${auth0Domain}/api/v2/`

// These are routes that exist on our homepage
const loginUrl = `${cursorHome}/api/auth/loginDeep`
const signUpUrl = `${cursorHome}/api/auth/loginDeep`
const settingsUrl = `${cursorHome}/settings`
const payUrl = `${cursorHome}/api/auth/checkoutDeep`
const loginUrl = `${HOMEPAGE_ROOT}/api/auth/loginDeep`
const signUpUrl = `${HOMEPAGE_ROOT}/api/auth/loginDeep`
const settingsUrl = `${HOMEPAGE_ROOT}/settings`
const payUrl = `${HOMEPAGE_ROOT}/pricing?fromCursor=true`

const supportUrl = `${API_ROOT}/auth/support`

Expand Down Expand Up @@ -128,7 +126,8 @@ export async function refreshTokens(event?: IpcMainInvokeEvent) {
}

accessToken = data.access_token
profile = jwtDecode(data.id_token)
const idToken = data.id_token
profile = jwtDecode(idToken)
} else {
// No refresh token
//throw new Error('No available refresh token.')
Expand Down Expand Up @@ -156,6 +155,7 @@ export async function setupTokens(
// Get the profile id from this
await refreshTokens()
await loadStripeProfile()

webContents.getAllWebContents().forEach((wc) => {
wc.send('updateAuthStatus', { accessToken, profile, stripeProfile })
})
Expand Down
5 changes: 2 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// export const API_ROOT = 'https://aicursor.com'
// export const API_ROOT = 'http://localhost:8000'
export const API_ROOT = 'https://staging.aicursor.com'
export const API_ROOT = 'https://aicursor.com'
export const HOMEPAGE_ROOT = 'https://cursor.so'

export class ExpectedBackendError extends Error {
public title: string | null = null;
Expand Down

0 comments on commit d5e1798

Please sign in to comment.