mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 11:42:30 +03: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
|
||||
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
|
||||
|
@ -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> => {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: defaultWidth,
|
||||
@ -146,6 +161,7 @@ const createWindow = async (): Promise<void> => {
|
||||
}
|
||||
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.
|
||||
|
@ -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)
|
||||
|
@ -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<void> {
|
||||
}
|
||||
|
||||
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<void> {
|
||||
} else {
|
||||
navigate({ path: [] })
|
||||
}
|
||||
|
||||
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> {
|
||||
ipcRenderer.send('set-front-cookie', host, name, value)
|
||||
},
|
||||
|
@ -81,6 +81,7 @@ export interface IPCMainExposed {
|
||||
sendNotification: (notififationParams: NotificationParams) => void
|
||||
getScreenAccess: () => Promise<boolean>
|
||||
getScreenSources: () => Promise<ScreenSource[]>
|
||||
handleAuth: (callback: (token: string) => void) => void
|
||||
|
||||
cancelBackup: () => void
|
||||
startBackup: (token: string, endpoint: string, workspace: string) => void
|
||||
|
@ -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
|
||||
</script>
|
||||
@ -28,7 +28,16 @@
|
||||
<span><Label label={action.caption} /></span>
|
||||
{/if}
|
||||
{#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}
|
||||
<a href="." on:click|preventDefault={action.func}><Label label={action.i18n} /></a>
|
||||
{/if}
|
||||
|
@ -169,7 +169,12 @@
|
||||
{#if workspaces.length}
|
||||
<div>
|
||||
<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>
|
||||
{/if}
|
||||
<div>
|
||||
|
Loading…
Reference in New Issue
Block a user