mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03:00
Fix guest links (#6172)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
8b44249cec
commit
abc5c2979d
@ -132,6 +132,7 @@ export default plugin(presentationId, {
|
||||
CollaboratorUrl: '' as Metadata<string>,
|
||||
CollaboratorApiUrl: '' as Metadata<string>,
|
||||
Token: '' as Metadata<string>,
|
||||
Endpoint: '' as Metadata<string>,
|
||||
FrontUrl: '' as Asset,
|
||||
PreviewConfig: '' as Metadata<PreviewConfig | undefined>,
|
||||
ClientHook: '' as Metadata<ClientHook>
|
||||
|
@ -46,6 +46,7 @@ export async function connect (title: string): Promise<Client | undefined> {
|
||||
}
|
||||
|
||||
setMetadata(presentation.metadata.Token, token)
|
||||
setMetadata(presentation.metadata.Endpoint, workspaceLoginInfo.endpoint)
|
||||
|
||||
if (_token !== token && _client !== undefined) {
|
||||
await _client.close()
|
||||
|
@ -1,7 +1,7 @@
|
||||
import client from '@hcengineering/client'
|
||||
import { type Doc } from '@hcengineering/core'
|
||||
import login from '@hcengineering/login'
|
||||
import { getResource, setMetadata } from '@hcengineering/platform'
|
||||
import { getMetadata, getResource, setMetadata } from '@hcengineering/platform'
|
||||
import presentation from '@hcengineering/presentation'
|
||||
import { fetchMetadataLocalStorage, getCurrentLocation, navigate } from '@hcengineering/ui'
|
||||
import view from '@hcengineering/view'
|
||||
@ -13,9 +13,8 @@ export async function checkAccess (doc: Doc): Promise<void> {
|
||||
const ws = loc.path[1]
|
||||
const tokens: Record<string, string> = fetchMetadataLocalStorage(login.metadata.LoginTokens) ?? {}
|
||||
const token = tokens[ws]
|
||||
if (token === undefined) return
|
||||
const getEndpoint = await getResource(login.function.GetEndpoint)
|
||||
const endpoint = await getEndpoint()
|
||||
const endpoint = getMetadata(presentation.metadata.Endpoint)
|
||||
if (token === undefined || endpoint === undefined) return
|
||||
const clientFactory = await getResource(client.function.GetClient)
|
||||
const _client = await clientFactory(token, endpoint)
|
||||
|
||||
|
@ -23,7 +23,6 @@ import {
|
||||
leaveWorkspace,
|
||||
selectWorkspace,
|
||||
sendInvite,
|
||||
getEnpoint,
|
||||
fetchWorkspace,
|
||||
createMissingEmployee,
|
||||
getInviteLink
|
||||
@ -48,7 +47,6 @@ export default async () => ({
|
||||
CreateEmployee: createMissingEmployee,
|
||||
GetWorkspaces: getWorkspaces,
|
||||
SendInvite: sendInvite,
|
||||
GetEndpoint: getEnpoint,
|
||||
GetInviteLink: getInviteLink
|
||||
}
|
||||
})
|
||||
|
@ -824,36 +824,6 @@ export async function afterConfirm (): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getEnpoint (): Promise<string | undefined> {
|
||||
const accountsUrl = getMetadata(login.metadata.AccountsUrl)
|
||||
|
||||
if (accountsUrl === undefined) {
|
||||
throw new Error('accounts url not specified')
|
||||
}
|
||||
|
||||
const params: [] = []
|
||||
|
||||
const request = {
|
||||
method: 'getEndpoint',
|
||||
params
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(accountsUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(request)
|
||||
})
|
||||
const result = await response.json()
|
||||
return result.result
|
||||
} catch (err: any) {
|
||||
console.error('get endpoint error', err)
|
||||
Analytics.handleError(err)
|
||||
}
|
||||
}
|
||||
|
||||
export async function getSessionLoginInfo (): Promise<LoginInfo | WorkspaceLoginInfo | undefined> {
|
||||
const accountsUrl = getMetadata(login.metadata.AccountsUrl)
|
||||
|
||||
|
@ -95,7 +95,6 @@ export default plugin(loginId, {
|
||||
>,
|
||||
FetchWorkspace: '' as Resource<(workspace: string) => Promise<[Status, WorkspaceLoginInfo | undefined]>>,
|
||||
CreateEmployee: '' as Resource<(workspace: string) => Promise<[Status]>>,
|
||||
GetWorkspaces: '' as Resource<() => Promise<Workspace[]>>,
|
||||
GetEndpoint: '' as Resource<() => Promise<string>>
|
||||
GetWorkspaces: '' as Resource<() => Promise<Workspace[]>>
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user