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.
|
||||
//
|
||||
|
||||
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 { v4 as uuid } from 'uuid'
|
||||
|
||||
@ -99,9 +99,9 @@ function getFilesUrl (): string {
|
||||
return filesUrl.includes('://') ? filesUrl : concatLink(frontUrl, filesUrl)
|
||||
}
|
||||
|
||||
export function getCurrentWorkspaceUuid (): WorkspaceDataId {
|
||||
export function getCurrentWorkspaceUuid (): WorkspaceUuid {
|
||||
const workspaceUuid = getMetadata(plugin.metadata.WorkspaceUuid) ?? ''
|
||||
return workspaceUuid as WorkspaceDataId
|
||||
return workspaceUuid as WorkspaceUuid
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,7 @@ import core, {
|
||||
type TxResult,
|
||||
type TypeAny,
|
||||
type WithLookup,
|
||||
type WorkspaceDataId
|
||||
type WorkspaceUuid
|
||||
} from '@hcengineering/core'
|
||||
import { getMetadata, getResource } from '@hcengineering/platform'
|
||||
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)
|
||||
}
|
||||
|
||||
export function setPresentationCookie (token: string, workspaceUuid: WorkspaceDataId): void {
|
||||
export function setPresentationCookie (token: string, workspaceUuid: WorkspaceUuid): void {
|
||||
function setToken (path: string): void {
|
||||
const res =
|
||||
encodeURIComponent(plugin.metadata.Token.replaceAll(':', '-')) +
|
||||
|
@ -9,7 +9,6 @@ import core, {
|
||||
type Client,
|
||||
type Version,
|
||||
type Ref,
|
||||
type WorkspaceDataId,
|
||||
type PersonId
|
||||
} from '@hcengineering/core'
|
||||
import { setCurrentEmployee, type Employee } from '@hcengineering/contact'
|
||||
@ -65,10 +64,7 @@ export async function connect (title: string): Promise<Client | undefined> {
|
||||
return
|
||||
}
|
||||
|
||||
setPresentationCookie(
|
||||
token,
|
||||
workspaceLoginInfo.workspaceDataId ?? (workspaceLoginInfo.workspace as unknown as WorkspaceDataId)
|
||||
)
|
||||
setPresentationCookie(token, workspaceLoginInfo.workspace)
|
||||
|
||||
setMetadata(presentation.metadata.Token, token)
|
||||
setMetadata(presentation.metadata.WorkspaceUuid, workspaceLoginInfo.workspace)
|
||||
@ -253,7 +249,7 @@ function clearMetadata (ws: string): void {
|
||||
delete tokens[loc.path[1]]
|
||||
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
|
||||
}
|
||||
const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid) as unknown as WorkspaceDataId
|
||||
const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid)
|
||||
if (currentWorkspace !== undefined) {
|
||||
setPresentationCookie('', currentWorkspace)
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import core, {
|
||||
type MeasureMetricsContext,
|
||||
type Version,
|
||||
pickPrimarySocialId,
|
||||
type WorkspaceDataId,
|
||||
type Person as GlobalPerson
|
||||
} from '@hcengineering/core'
|
||||
import { setCurrentEmployee, ensureEmployee } from '@hcengineering/contact'
|
||||
@ -148,10 +147,7 @@ export async function connect (title: string): Promise<Client | undefined> {
|
||||
}
|
||||
}
|
||||
|
||||
setPresentationCookie(
|
||||
token,
|
||||
workspaceLoginInfo.workspaceDataId ?? (workspaceLoginInfo.workspace as unknown as WorkspaceDataId)
|
||||
)
|
||||
setPresentationCookie(token, workspaceLoginInfo.workspace)
|
||||
setMetadataLocalStorage(login.metadata.LoginEndpoint, 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]]
|
||||
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
|
||||
}
|
||||
const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid) as unknown as WorkspaceDataId
|
||||
const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid)
|
||||
if (currentWorkspace !== undefined) {
|
||||
setPresentationCookie('', currentWorkspace)
|
||||
}
|
||||
|
@ -15,14 +15,7 @@
|
||||
//
|
||||
|
||||
import { Analytics } from '@hcengineering/analytics'
|
||||
import {
|
||||
MeasureContext,
|
||||
Blob as PlatformBlob,
|
||||
WorkspaceDataId,
|
||||
WorkspaceIds,
|
||||
metricsAggregate,
|
||||
type Ref
|
||||
} from '@hcengineering/core'
|
||||
import { MeasureContext, Blob as PlatformBlob, WorkspaceIds, metricsAggregate, type Ref } from '@hcengineering/core'
|
||||
import { TokenError, decodeToken } from '@hcengineering/server-token'
|
||||
import { StorageAdapter } from '@hcengineering/storage'
|
||||
import bp from 'body-parser'
|
||||
@ -429,16 +422,16 @@ export function start (
|
||||
dataId: workspaceInfo.dataId,
|
||||
url: workspaceInfo.url
|
||||
}
|
||||
const actualDataId = workspaceInfo.dataId ?? (workspaceInfo.uuid as unknown as WorkspaceDataId)
|
||||
if (path === undefined) {
|
||||
return wsIds
|
||||
}
|
||||
|
||||
const expectedDataId = path.split('/')[2]
|
||||
if (expectedDataId !== undefined && actualDataId !== expectedDataId) {
|
||||
ctx.error('Cannot validate dataId', {
|
||||
expectedDataId,
|
||||
actualDataId,
|
||||
const actualUuid = workspaceInfo.uuid
|
||||
const expectedUuid = path.split('/')[2]
|
||||
if (expectedUuid !== undefined && actualUuid !== expectedUuid) {
|
||||
ctx.error('Cannot validate uuid', {
|
||||
expectedUuid,
|
||||
actualUuid,
|
||||
path,
|
||||
workspaceUuid: workspaceInfo.uuid,
|
||||
workspaceDataId: workspaceInfo.dataId
|
||||
|
Loading…
Reference in New Issue
Block a user