mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-16 05:13:06 +00:00
UBERF-8427: Fix desktop oauth flow (#6975)
Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
parent
913849af82
commit
f4393df8f3
@ -1483,7 +1483,7 @@ dependencies:
|
|||||||
version: 22.8.8
|
version: 22.8.8
|
||||||
electron:
|
electron:
|
||||||
specifier: ^32.1.1
|
specifier: ^32.1.1
|
||||||
version: 32.1.1
|
version: 32.2.1
|
||||||
electron-builder:
|
electron-builder:
|
||||||
specifier: ^25.0.5
|
specifier: ^25.0.5
|
||||||
version: 25.0.5
|
version: 25.0.5
|
||||||
@ -13754,8 +13754,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-hWFbUk9u3fQHcKzTAcjZAN7XH9bL9oH9g20RRDU/DVDNqdMI03GzlBZfR/R8R1krYu9AT4biLqSCAxnt9LMAfA==}
|
resolution: {integrity: sha512-hWFbUk9u3fQHcKzTAcjZAN7XH9bL9oH9g20RRDU/DVDNqdMI03GzlBZfR/R8R1krYu9AT4biLqSCAxnt9LMAfA==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/electron@32.1.1:
|
/electron@32.2.1:
|
||||||
resolution: {integrity: sha512-NlWvG6kXOJbZbELmzP3oV7u50I3NHYbCeh+AkUQ9vGyP7b74cFMx9HdTzejODeztW1jhr3SjIBbUZzZ45zflfQ==}
|
resolution: {integrity: sha512-GCPI/5hU34pPcNltNpz+uylhhuTm9BM0N8RmrbVgaWBodLSmmcCkvpgN0BseKhO6IwQOPzWaovrcZ/nPIpfGaQ==}
|
||||||
engines: {node: '>= 12.20.55'}
|
engines: {node: '>= 12.20.55'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
@ -27126,7 +27126,7 @@ packages:
|
|||||||
'@vercel/webpack-asset-relocator-loader': 1.7.4
|
'@vercel/webpack-asset-relocator-loader': 1.7.4
|
||||||
cross-env: 7.0.3
|
cross-env: 7.0.3
|
||||||
dotenv: 16.0.3
|
dotenv: 16.0.3
|
||||||
electron: 32.1.1
|
electron: 32.2.1
|
||||||
electron-builder: 25.0.5
|
electron-builder: 25.0.5
|
||||||
electron-squirrel-startup: 1.0.1
|
electron-squirrel-startup: 1.0.1
|
||||||
node-loader: 2.0.0(webpack@5.90.3)
|
node-loader: 2.0.0(webpack@5.90.3)
|
||||||
@ -27262,7 +27262,7 @@ packages:
|
|||||||
css-loader: 5.2.7(webpack@5.90.3)
|
css-loader: 5.2.7(webpack@5.90.3)
|
||||||
dotenv: 16.0.3
|
dotenv: 16.0.3
|
||||||
dotenv-webpack: 8.0.1(webpack@5.90.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-context-menu: 4.0.4
|
||||||
electron-log: 5.1.7
|
electron-log: 5.1.7
|
||||||
electron-squirrel-startup: 1.0.1
|
electron-squirrel-startup: 1.0.1
|
||||||
|
@ -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<void> => {
|
||||||
|
await window.loadFile(path.join('dist', 'ui', 'index.html'))
|
||||||
|
window.webContents.send('handle-auth', urlObj.searchParams.get('token'))
|
||||||
|
})()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const createWindow = async (): Promise<void> => {
|
const createWindow = async (): Promise<void> => {
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: defaultWidth,
|
width: defaultWidth,
|
||||||
@ -146,6 +161,7 @@ const createWindow = async (): Promise<void> => {
|
|||||||
}
|
}
|
||||||
await mainWindow.loadFile(path.join('dist', 'ui', 'index.html'))
|
await mainWindow.loadFile(path.join('dist', 'ui', 'index.html'))
|
||||||
addPermissionHandlers(mainWindow.webContents.session)
|
addPermissionHandlers(mainWindow.webContents.session)
|
||||||
|
handleAuthRedirects(mainWindow)
|
||||||
|
|
||||||
// In this example, only windows with the `about:blank` url will be created.
|
// In this example, only windows with the `about:blank` url will be created.
|
||||||
// All other urls will be blocked.
|
// All other urls will be blocked.
|
||||||
|
@ -92,6 +92,15 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
setDownloadProgress(progress)
|
setDownloadProgress(progress)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcMain.handleAuth((token) => {
|
||||||
|
const authLoc = {
|
||||||
|
path: ['login', 'auth'],
|
||||||
|
query: { token }
|
||||||
|
}
|
||||||
|
|
||||||
|
navigate(authLoc)
|
||||||
|
})
|
||||||
|
|
||||||
ipcMain.on('start-backup', () => {
|
ipcMain.on('start-backup', () => {
|
||||||
// We need to obtain current token and endpoint and trigger backup
|
// We need to obtain current token and endpoint and trigger backup
|
||||||
const token = getMetadata(presentation.metadata.Token)
|
const token = getMetadata(presentation.metadata.Token)
|
||||||
|
@ -39,7 +39,7 @@ import { taskId } from '@hcengineering/task'
|
|||||||
import telegram, { telegramId } from '@hcengineering/telegram'
|
import telegram, { telegramId } from '@hcengineering/telegram'
|
||||||
import { templatesId } from '@hcengineering/templates'
|
import { templatesId } from '@hcengineering/templates'
|
||||||
import tracker, { trackerId } from '@hcengineering/tracker'
|
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 { uploaderId } from '@hcengineering/uploader'
|
||||||
import { viewId } from '@hcengineering/view'
|
import { viewId } from '@hcengineering/view'
|
||||||
import workbench, { workbenchId } from '@hcengineering/workbench'
|
import workbench, { workbenchId } from '@hcengineering/workbench'
|
||||||
@ -337,6 +337,7 @@ export async function configurePlatform (): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const last = localStorage.getItem(locationStorageKeyId)
|
const last = localStorage.getItem(locationStorageKeyId)
|
||||||
|
|
||||||
if (config.INITIAL_URL !== '') {
|
if (config.INITIAL_URL !== '') {
|
||||||
console.log('NAVIGATE', config.INITIAL_URL, getCurrentLocation())
|
console.log('NAVIGATE', config.INITIAL_URL, getCurrentLocation())
|
||||||
// NavigationExpandedDefault=false fills buggy:
|
// NavigationExpandedDefault=false fills buggy:
|
||||||
@ -353,5 +354,6 @@ export async function configurePlatform (): Promise<void> {
|
|||||||
} else {
|
} else {
|
||||||
navigate({ path: [] })
|
navigate({ path: [] })
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Initial location is: ', getCurrentLocation())
|
console.log('Initial location is: ', getCurrentLocation())
|
||||||
}
|
}
|
||||||
|
@ -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<void> {
|
async setFrontCookie (host: string, name: string, value: string): Promise<void> {
|
||||||
ipcRenderer.send('set-front-cookie', host, name, value)
|
ipcRenderer.send('set-front-cookie', host, name, value)
|
||||||
},
|
},
|
||||||
|
@ -81,6 +81,7 @@ export interface IPCMainExposed {
|
|||||||
sendNotification: (notififationParams: NotificationParams) => void
|
sendNotification: (notififationParams: NotificationParams) => void
|
||||||
getScreenAccess: () => Promise<boolean>
|
getScreenAccess: () => Promise<boolean>
|
||||||
getScreenSources: () => Promise<ScreenSource[]>
|
getScreenSources: () => Promise<ScreenSource[]>
|
||||||
|
handleAuth: (callback: (token: string) => void) => void
|
||||||
|
|
||||||
cancelBackup: () => void
|
cancelBackup: () => void
|
||||||
startBackup: (token: string, endpoint: string, workspace: string) => void
|
startBackup: (token: string, endpoint: string, workspace: string) => void
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import { NavLink } from '@hcengineering/presentation'
|
import { NavLink } from '@hcengineering/presentation'
|
||||||
|
|
||||||
import { getHref } from '../utils'
|
import { getHref } from '../utils'
|
||||||
import { BottomAction } from '../index'
|
import { BottomAction, goTo } from '../index'
|
||||||
|
|
||||||
export let action: BottomAction
|
export let action: BottomAction
|
||||||
</script>
|
</script>
|
||||||
@ -28,7 +28,16 @@
|
|||||||
<span><Label label={action.caption} /></span>
|
<span><Label label={action.caption} /></span>
|
||||||
{/if}
|
{/if}
|
||||||
{#if action.page}
|
{#if action.page}
|
||||||
<NavLink href={getHref(action.page)}><Label label={action.i18n} /></NavLink>
|
<NavLink
|
||||||
|
href={getHref(action.page)}
|
||||||
|
onClick={() => {
|
||||||
|
if (action.func !== undefined) {
|
||||||
|
action.func()
|
||||||
|
} else if (action.page !== undefined) {
|
||||||
|
goTo(action.page)
|
||||||
|
}
|
||||||
|
}}><Label label={action.i18n} /></NavLink
|
||||||
|
>
|
||||||
{:else}
|
{:else}
|
||||||
<a href="." on:click|preventDefault={action.func}><Label label={action.i18n} /></a>
|
<a href="." on:click|preventDefault={action.func}><Label label={action.i18n} /></a>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -169,7 +169,12 @@
|
|||||||
{#if workspaces.length}
|
{#if workspaces.length}
|
||||||
<div>
|
<div>
|
||||||
<span><Label label={login.string.WantAnotherWorkspace} /></span>
|
<span><Label label={login.string.WantAnotherWorkspace} /></span>
|
||||||
<NavLink href={getHref('createWorkspace')}><Label label={login.string.CreateWorkspace} /></NavLink>
|
<NavLink
|
||||||
|
href={getHref('createWorkspace')}
|
||||||
|
onClick={() => {
|
||||||
|
goTo('createWorkspace')
|
||||||
|
}}><Label label={login.string.CreateWorkspace} /></NavLink
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div>
|
<div>
|
||||||
|
Loading…
Reference in New Issue
Block a user