another test auth tweak
This commit is contained in:
@ -688,6 +688,8 @@ export async function setupElectron({
|
||||
...process.env,
|
||||
TEST_SETTINGS_FILE_KEY: projectDirName,
|
||||
IS_PLAYWRIGHT: 'true',
|
||||
SKIP_AUTH: 'true',
|
||||
DEV_TOKEN: secrets.token,
|
||||
},
|
||||
})
|
||||
const context = electronApp.context()
|
||||
|
||||
2
interface.d.ts
vendored
2
interface.d.ts
vendored
@ -37,6 +37,8 @@ export interface IElectronAPI {
|
||||
BASE_URL: EnvFn
|
||||
TEST_SETTINGS_FILE_KEY: EnvFn
|
||||
IS_PLAYWRIGHT: EnvFn
|
||||
SKIP_AUTH: EnvFn
|
||||
DEV_TOKEN: EnvFn
|
||||
}
|
||||
}
|
||||
kittycad: (access: string, args: any) => any
|
||||
|
||||
@ -8,7 +8,8 @@ import { COOKIE_NAME } from 'lib/constants'
|
||||
|
||||
const SKIP_AUTH =
|
||||
// @ts-ignore
|
||||
import.meta.env.VITE_KC_SKIP_AUTH === 'true' && import.meta.env.DEV
|
||||
(import.meta.env.VITE_KC_SKIP_AUTH === 'true' && import.meta.env.DEV) ||
|
||||
window.electron.process.env.SKIP_AUTH()
|
||||
|
||||
const LOCAL_USER: Models['User_type'] = {
|
||||
id: '8675309',
|
||||
@ -121,8 +122,8 @@ export const authMachine = createMachine<UserContext, Events>(
|
||||
)
|
||||
|
||||
async function getUser(context: UserContext) {
|
||||
const token = VITE_KC_DEV_TOKEN
|
||||
? VITE_KC_DEV_TOKEN
|
||||
const token = VITE_KC_DEV_TOKEN || window.electron.process.env.DEV_TOKEN()
|
||||
? VITE_KC_DEV_TOKEN || window.electron.process.env.DEV_TOKEN()
|
||||
: context.token && context.token !== ''
|
||||
? context.token
|
||||
: getCookie(COOKIE_NAME) || localStorage?.getItem(TOKEN_PERSIST_KEY)
|
||||
|
||||
@ -86,7 +86,13 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
// these are read-only over the boundary.
|
||||
env: Object.assign(
|
||||
{},
|
||||
exposeProcessEnvs(['BASE_URL', 'TEST_SETTINGS_FILE_KEY', 'IS_PLAYWRIGHT'])
|
||||
exposeProcessEnvs([
|
||||
'BASE_URL',
|
||||
'TEST_SETTINGS_FILE_KEY',
|
||||
'IS_PLAYWRIGHT',
|
||||
'SKIP_AUTH',
|
||||
'DEV_TOKEN',
|
||||
])
|
||||
),
|
||||
},
|
||||
kittycad,
|
||||
|
||||
Reference in New Issue
Block a user