mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-01 12:47:46 +00:00
fix: use workspace uuid in front service (#8024)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
parent
2f27d09a05
commit
8d3015bd47
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
import { concatLink, type WorkspaceDataId, type Blob as PlatformBlob, type Ref } from '@hcengineering/core'
|
import { concatLink, type Blob as PlatformBlob, type Ref, type WorkspaceUuid } from '@hcengineering/core'
|
||||||
import { PlatformError, Severity, Status, getMetadata } from '@hcengineering/platform'
|
import { PlatformError, Severity, Status, getMetadata } from '@hcengineering/platform'
|
||||||
import { v4 as uuid } from 'uuid'
|
import { v4 as uuid } from 'uuid'
|
||||||
|
|
||||||
@ -99,9 +99,9 @@ function getFilesUrl (): string {
|
|||||||
return filesUrl.includes('://') ? filesUrl : concatLink(frontUrl, filesUrl)
|
return filesUrl.includes('://') ? filesUrl : concatLink(frontUrl, filesUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCurrentWorkspaceUuid (): WorkspaceDataId {
|
export function getCurrentWorkspaceUuid (): WorkspaceUuid {
|
||||||
const workspaceUuid = getMetadata(plugin.metadata.WorkspaceUuid) ?? ''
|
const workspaceUuid = getMetadata(plugin.metadata.WorkspaceUuid) ?? ''
|
||||||
return workspaceUuid as WorkspaceDataId
|
return workspaceUuid as WorkspaceUuid
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +47,7 @@ import core, {
|
|||||||
type TxResult,
|
type TxResult,
|
||||||
type TypeAny,
|
type TypeAny,
|
||||||
type WithLookup,
|
type WithLookup,
|
||||||
type WorkspaceDataId
|
type WorkspaceUuid
|
||||||
} from '@hcengineering/core'
|
} from '@hcengineering/core'
|
||||||
import { getMetadata, getResource } from '@hcengineering/platform'
|
import { getMetadata, getResource } from '@hcengineering/platform'
|
||||||
import { LiveQuery as LQ } from '@hcengineering/query'
|
import { LiveQuery as LQ } from '@hcengineering/query'
|
||||||
@ -763,7 +763,7 @@ export function isSpaceClass (_class: Ref<Class<Doc>>): boolean {
|
|||||||
return client.getHierarchy().isDerived(_class, core.class.Space)
|
return client.getHierarchy().isDerived(_class, core.class.Space)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setPresentationCookie (token: string, workspaceUuid: WorkspaceDataId): void {
|
export function setPresentationCookie (token: string, workspaceUuid: WorkspaceUuid): void {
|
||||||
function setToken (path: string): void {
|
function setToken (path: string): void {
|
||||||
const res =
|
const res =
|
||||||
encodeURIComponent(plugin.metadata.Token.replaceAll(':', '-')) +
|
encodeURIComponent(plugin.metadata.Token.replaceAll(':', '-')) +
|
||||||
|
@ -9,7 +9,6 @@ import core, {
|
|||||||
type Client,
|
type Client,
|
||||||
type Version,
|
type Version,
|
||||||
type Ref,
|
type Ref,
|
||||||
type WorkspaceDataId,
|
|
||||||
type PersonId
|
type PersonId
|
||||||
} from '@hcengineering/core'
|
} from '@hcengineering/core'
|
||||||
import { setCurrentEmployee, type Employee } from '@hcengineering/contact'
|
import { setCurrentEmployee, type Employee } from '@hcengineering/contact'
|
||||||
@ -65,10 +64,7 @@ export async function connect (title: string): Promise<Client | undefined> {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setPresentationCookie(
|
setPresentationCookie(token, workspaceLoginInfo.workspace)
|
||||||
token,
|
|
||||||
workspaceLoginInfo.workspaceDataId ?? (workspaceLoginInfo.workspace as unknown as WorkspaceDataId)
|
|
||||||
)
|
|
||||||
|
|
||||||
setMetadata(presentation.metadata.Token, token)
|
setMetadata(presentation.metadata.Token, token)
|
||||||
setMetadata(presentation.metadata.WorkspaceUuid, workspaceLoginInfo.workspace)
|
setMetadata(presentation.metadata.WorkspaceUuid, workspaceLoginInfo.workspace)
|
||||||
@ -253,7 +249,7 @@ function clearMetadata (ws: string): void {
|
|||||||
delete tokens[loc.path[1]]
|
delete tokens[loc.path[1]]
|
||||||
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
|
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
|
||||||
}
|
}
|
||||||
const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid) as unknown as WorkspaceDataId
|
const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid)
|
||||||
if (currentWorkspace !== undefined) {
|
if (currentWorkspace !== undefined) {
|
||||||
setPresentationCookie('', currentWorkspace)
|
setPresentationCookie('', currentWorkspace)
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import core, {
|
|||||||
type MeasureMetricsContext,
|
type MeasureMetricsContext,
|
||||||
type Version,
|
type Version,
|
||||||
pickPrimarySocialId,
|
pickPrimarySocialId,
|
||||||
type WorkspaceDataId,
|
|
||||||
type Person as GlobalPerson
|
type Person as GlobalPerson
|
||||||
} from '@hcengineering/core'
|
} from '@hcengineering/core'
|
||||||
import { setCurrentEmployee, ensureEmployee } from '@hcengineering/contact'
|
import { setCurrentEmployee, ensureEmployee } from '@hcengineering/contact'
|
||||||
@ -148,10 +147,7 @@ export async function connect (title: string): Promise<Client | undefined> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setPresentationCookie(
|
setPresentationCookie(token, workspaceLoginInfo.workspace)
|
||||||
token,
|
|
||||||
workspaceLoginInfo.workspaceDataId ?? (workspaceLoginInfo.workspace as unknown as WorkspaceDataId)
|
|
||||||
)
|
|
||||||
setMetadataLocalStorage(login.metadata.LoginEndpoint, workspaceLoginInfo?.endpoint)
|
setMetadataLocalStorage(login.metadata.LoginEndpoint, workspaceLoginInfo?.endpoint)
|
||||||
|
|
||||||
const endpoint = getMetadata(login.metadata.TransactorOverride) ?? workspaceLoginInfo?.endpoint
|
const endpoint = getMetadata(login.metadata.TransactorOverride) ?? workspaceLoginInfo?.endpoint
|
||||||
@ -445,7 +441,7 @@ export function clearMetadata (ws: string): void {
|
|||||||
delete tokens[loc.path[1]]
|
delete tokens[loc.path[1]]
|
||||||
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
|
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
|
||||||
}
|
}
|
||||||
const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid) as unknown as WorkspaceDataId
|
const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid)
|
||||||
if (currentWorkspace !== undefined) {
|
if (currentWorkspace !== undefined) {
|
||||||
setPresentationCookie('', currentWorkspace)
|
setPresentationCookie('', currentWorkspace)
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { Analytics } from '@hcengineering/analytics'
|
import { Analytics } from '@hcengineering/analytics'
|
||||||
import {
|
import { MeasureContext, Blob as PlatformBlob, WorkspaceIds, metricsAggregate, type Ref } from '@hcengineering/core'
|
||||||
MeasureContext,
|
|
||||||
Blob as PlatformBlob,
|
|
||||||
WorkspaceDataId,
|
|
||||||
WorkspaceIds,
|
|
||||||
metricsAggregate,
|
|
||||||
type Ref
|
|
||||||
} from '@hcengineering/core'
|
|
||||||
import { TokenError, decodeToken } from '@hcengineering/server-token'
|
import { TokenError, decodeToken } from '@hcengineering/server-token'
|
||||||
import { StorageAdapter } from '@hcengineering/storage'
|
import { StorageAdapter } from '@hcengineering/storage'
|
||||||
import bp from 'body-parser'
|
import bp from 'body-parser'
|
||||||
@ -429,16 +422,16 @@ export function start (
|
|||||||
dataId: workspaceInfo.dataId,
|
dataId: workspaceInfo.dataId,
|
||||||
url: workspaceInfo.url
|
url: workspaceInfo.url
|
||||||
}
|
}
|
||||||
const actualDataId = workspaceInfo.dataId ?? (workspaceInfo.uuid as unknown as WorkspaceDataId)
|
|
||||||
if (path === undefined) {
|
if (path === undefined) {
|
||||||
return wsIds
|
return wsIds
|
||||||
}
|
}
|
||||||
|
|
||||||
const expectedDataId = path.split('/')[2]
|
const actualUuid = workspaceInfo.uuid
|
||||||
if (expectedDataId !== undefined && actualDataId !== expectedDataId) {
|
const expectedUuid = path.split('/')[2]
|
||||||
ctx.error('Cannot validate dataId', {
|
if (expectedUuid !== undefined && actualUuid !== expectedUuid) {
|
||||||
expectedDataId,
|
ctx.error('Cannot validate uuid', {
|
||||||
actualDataId,
|
expectedUuid,
|
||||||
|
actualUuid,
|
||||||
path,
|
path,
|
||||||
workspaceUuid: workspaceInfo.uuid,
|
workspaceUuid: workspaceInfo.uuid,
|
||||||
workspaceDataId: workspaceInfo.dataId
|
workspaceDataId: workspaceInfo.dataId
|
||||||
|
Loading…
Reference in New Issue
Block a user