diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index b4d7a40838..f07ee37bdb 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1483,7 +1483,7 @@ dependencies: version: 22.8.8 electron: specifier: ^32.1.1 - version: 32.1.1 + version: 32.2.1 electron-builder: specifier: ^25.0.5 version: 25.0.5 @@ -13754,8 +13754,8 @@ packages: resolution: {integrity: sha512-hWFbUk9u3fQHcKzTAcjZAN7XH9bL9oH9g20RRDU/DVDNqdMI03GzlBZfR/R8R1krYu9AT4biLqSCAxnt9LMAfA==} dev: false - /electron@32.1.1: - resolution: {integrity: sha512-NlWvG6kXOJbZbELmzP3oV7u50I3NHYbCeh+AkUQ9vGyP7b74cFMx9HdTzejODeztW1jhr3SjIBbUZzZ45zflfQ==} + /electron@32.2.1: + resolution: {integrity: sha512-GCPI/5hU34pPcNltNpz+uylhhuTm9BM0N8RmrbVgaWBodLSmmcCkvpgN0BseKhO6IwQOPzWaovrcZ/nPIpfGaQ==} engines: {node: '>= 12.20.55'} hasBin: true requiresBuild: true @@ -27126,7 +27126,7 @@ packages: '@vercel/webpack-asset-relocator-loader': 1.7.4 cross-env: 7.0.3 dotenv: 16.0.3 - electron: 32.1.1 + electron: 32.2.1 electron-builder: 25.0.5 electron-squirrel-startup: 1.0.1 node-loader: 2.0.0(webpack@5.90.3) @@ -27262,7 +27262,7 @@ packages: css-loader: 5.2.7(webpack@5.90.3) dotenv: 16.0.3 dotenv-webpack: 8.0.1(webpack@5.90.3) - electron: 32.1.1 + electron: 32.2.1 electron-context-menu: 4.0.4 electron-log: 5.1.7 electron-squirrel-startup: 1.0.1 diff --git a/desktop/src/main/start.ts b/desktop/src/main/start.ts index 731aa1022a..b4e96f7ac0 100644 --- a/desktop/src/main/start.ts +++ b/desktop/src/main/start.ts @@ -124,6 +124,21 @@ function hookOpenWindow (window: BrowserWindow): void { }) } +function handleAuthRedirects (window: BrowserWindow): void { + window.webContents.on('will-redirect', (event) => { + if (event?.url.startsWith(`${FRONT_URL}/login/auth`)) { + console.log('Auth happened, redirecting to local index') + const urlObj = new URL(decodeURIComponent(event.url)) + event.preventDefault() + + void (async (): Promise => { + await window.loadFile(path.join('dist', 'ui', 'index.html')) + window.webContents.send('handle-auth', urlObj.searchParams.get('token')) + })() + } + }) +} + const createWindow = async (): Promise => { mainWindow = new BrowserWindow({ width: defaultWidth, @@ -146,6 +161,7 @@ const createWindow = async (): Promise => { } await mainWindow.loadFile(path.join('dist', 'ui', 'index.html')) addPermissionHandlers(mainWindow.webContents.session) + handleAuthRedirects(mainWindow) // In this example, only windows with the `about:blank` url will be created. // All other urls will be blocked. diff --git a/desktop/src/ui/index.ts b/desktop/src/ui/index.ts index 58b0443aaf..1a393b089a 100644 --- a/desktop/src/ui/index.ts +++ b/desktop/src/ui/index.ts @@ -92,6 +92,15 @@ window.addEventListener('DOMContentLoaded', () => { setDownloadProgress(progress) }) + ipcMain.handleAuth((token) => { + const authLoc = { + path: ['login', 'auth'], + query: { token } + } + + navigate(authLoc) + }) + ipcMain.on('start-backup', () => { // We need to obtain current token and endpoint and trigger backup const token = getMetadata(presentation.metadata.Token) diff --git a/desktop/src/ui/platform.ts b/desktop/src/ui/platform.ts index 0fb19be3e6..c43c95eeed 100644 --- a/desktop/src/ui/platform.ts +++ b/desktop/src/ui/platform.ts @@ -39,7 +39,7 @@ import { taskId } from '@hcengineering/task' import telegram, { telegramId } from '@hcengineering/telegram' import { templatesId } from '@hcengineering/templates' import tracker, { trackerId } from '@hcengineering/tracker' -import uiPlugin, { getCurrentLocation, locationStorageKeyId, navigate, setLocationStorageKey } from '@hcengineering/ui' +import uiPlugin, { getCurrentLocation, locationStorageKeyId, locationToUrl, navigate, parseLocation, setLocationStorageKey } from '@hcengineering/ui' import { uploaderId } from '@hcengineering/uploader' import { viewId } from '@hcengineering/view' import workbench, { workbenchId } from '@hcengineering/workbench' @@ -337,6 +337,7 @@ export async function configurePlatform (): Promise { } const last = localStorage.getItem(locationStorageKeyId) + if (config.INITIAL_URL !== '') { console.log('NAVIGATE', config.INITIAL_URL, getCurrentLocation()) // NavigationExpandedDefault=false fills buggy: @@ -353,5 +354,6 @@ export async function configurePlatform (): Promise { } else { navigate({ path: [] }) } + console.log('Initial location is: ', getCurrentLocation()) } diff --git a/desktop/src/ui/preload.ts b/desktop/src/ui/preload.ts index afd497a98f..a3984a4d9d 100644 --- a/desktop/src/ui/preload.ts +++ b/desktop/src/ui/preload.ts @@ -130,6 +130,12 @@ const expose: IPCMainExposed = { }) }, + handleAuth: (callback) => { + ipcRenderer.on('handle-auth', (event, value) => { + callback(value) + }) + }, + async setFrontCookie (host: string, name: string, value: string): Promise { ipcRenderer.send('set-front-cookie', host, name, value) }, diff --git a/desktop/src/ui/types.ts b/desktop/src/ui/types.ts index 6e9c37e474..a8d8e16450 100644 --- a/desktop/src/ui/types.ts +++ b/desktop/src/ui/types.ts @@ -81,6 +81,7 @@ export interface IPCMainExposed { sendNotification: (notififationParams: NotificationParams) => void getScreenAccess: () => Promise getScreenSources: () => Promise + handleAuth: (callback: (token: string) => void) => void cancelBackup: () => void startBackup: (token: string, endpoint: string, workspace: string) => void diff --git a/plugins/login-resources/src/components/BottomAction.svelte b/plugins/login-resources/src/components/BottomAction.svelte index 1d8d5e02c1..173b2e7105 100644 --- a/plugins/login-resources/src/components/BottomAction.svelte +++ b/plugins/login-resources/src/components/BottomAction.svelte @@ -18,7 +18,7 @@ import { NavLink } from '@hcengineering/presentation' import { getHref } from '../utils' - import { BottomAction } from '../index' + import { BottomAction, goTo } from '../index' export let action: BottomAction @@ -28,7 +28,16 @@ {/if} {#if action.page} - + { + if (action.func !== undefined) { + action.func() + } else if (action.page !== undefined) { + goTo(action.page) + } + }}> {:else} {/if} diff --git a/plugins/login-resources/src/components/SelectWorkspace.svelte b/plugins/login-resources/src/components/SelectWorkspace.svelte index 9e2b447fe6..fcb70f0180 100644 --- a/plugins/login-resources/src/components/SelectWorkspace.svelte +++ b/plugins/login-resources/src/components/SelectWorkspace.svelte @@ -169,7 +169,12 @@ {#if workspaces.length}
- + { + goTo('createWorkspace') + }}>
{/if}