mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-08 21:27:45 +03:00
Fix redirect url (#2775)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
d8bfb1c413
commit
2817f40b82
@ -15,9 +15,9 @@
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { OK, setMetadata, Severity, Status } from '@hcengineering/platform'
|
||||
import { getCurrentLocation, navigate, setMetadataLocalStorage } from '@hcengineering/ui'
|
||||
import { getCurrentLocation, navigate, Location, setMetadataLocalStorage } from '@hcengineering/ui'
|
||||
|
||||
import { doLogin } from '../utils'
|
||||
import { doLogin, getWorkspaces, navigateToWorkspace, selectWorkspace } from '../utils'
|
||||
import Form from './Form.svelte'
|
||||
|
||||
import login from '../plugin'
|
||||
@ -53,6 +53,26 @@
|
||||
setMetadata(login.metadata.LoginToken, result.token)
|
||||
setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint)
|
||||
setMetadataLocalStorage(login.metadata.LoginEmail, result.email)
|
||||
|
||||
if (navigateUrl !== undefined) {
|
||||
try {
|
||||
const loc = JSON.parse(decodeURIComponent(navigateUrl)) as Location
|
||||
const workspace = loc.path[1]
|
||||
if (workspace !== undefined) {
|
||||
const workspaces = await getWorkspaces()
|
||||
if (workspaces.find((p) => p.workspace === workspace) !== undefined) {
|
||||
status = new Status(Severity.INFO, login.status.ConnectingToServer, {})
|
||||
|
||||
const [loginStatus, result] = await selectWorkspace(workspace)
|
||||
status = loginStatus
|
||||
navigateToWorkspace(workspace, result, navigateUrl)
|
||||
return
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
// Json parse error could be ignored
|
||||
}
|
||||
}
|
||||
const loc = getCurrentLocation()
|
||||
loc.path[1] = 'selectWorkspace'
|
||||
loc.path.length = 2
|
||||
|
@ -292,12 +292,10 @@ export function navigateToWorkspace (workspace: string, loginInfo?: WorkspaceLog
|
||||
setLoginInfo(loginInfo)
|
||||
|
||||
if (navigateUrl !== undefined) {
|
||||
const loc = JSON.parse(decodeURIComponent(navigateUrl)) as Location
|
||||
try {
|
||||
const url = JSON.parse(decodeURIComponent(loc.query?.navigateUrl ?? '{}')) as Location
|
||||
if (url.path[1] === workspace) {
|
||||
navigate(url)
|
||||
|
||||
const loc = JSON.parse(decodeURIComponent(navigateUrl)) as Location
|
||||
if (loc.path[1] === workspace) {
|
||||
navigate(loc)
|
||||
return
|
||||
}
|
||||
} catch (err: any) {
|
||||
|
Loading…
Reference in New Issue
Block a user