diff --git a/packages/presentation/src/plugin.ts b/packages/presentation/src/plugin.ts index d4a7fd5f8b..d081075e85 100644 --- a/packages/presentation/src/plugin.ts +++ b/packages/presentation/src/plugin.ts @@ -132,6 +132,7 @@ export default plugin(presentationId, { CollaboratorUrl: '' as Metadata, CollaboratorApiUrl: '' as Metadata, Token: '' as Metadata, + Endpoint: '' as Metadata, FrontUrl: '' as Asset, PreviewConfig: '' as Metadata, ClientHook: '' as Metadata diff --git a/plugins/guest-resources/src/connect.ts b/plugins/guest-resources/src/connect.ts index 0324f77d87..181d387362 100644 --- a/plugins/guest-resources/src/connect.ts +++ b/plugins/guest-resources/src/connect.ts @@ -46,6 +46,7 @@ export async function connect (title: string): Promise { } setMetadata(presentation.metadata.Token, token) + setMetadata(presentation.metadata.Endpoint, workspaceLoginInfo.endpoint) if (_token !== token && _client !== undefined) { await _client.close() diff --git a/plugins/guest-resources/src/utils.ts b/plugins/guest-resources/src/utils.ts index 8ad04dfb9a..ece1ad820b 100644 --- a/plugins/guest-resources/src/utils.ts +++ b/plugins/guest-resources/src/utils.ts @@ -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 { const ws = loc.path[1] const tokens: Record = 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) diff --git a/plugins/login-resources/src/index.ts b/plugins/login-resources/src/index.ts index 4a461341c1..608a0a03a8 100644 --- a/plugins/login-resources/src/index.ts +++ b/plugins/login-resources/src/index.ts @@ -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 } }) diff --git a/plugins/login-resources/src/utils.ts b/plugins/login-resources/src/utils.ts index 13799357a2..584016f7c5 100644 --- a/plugins/login-resources/src/utils.ts +++ b/plugins/login-resources/src/utils.ts @@ -824,36 +824,6 @@ export async function afterConfirm (): Promise { } } -export async function getEnpoint (): Promise { - 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 { const accountsUrl = getMetadata(login.metadata.AccountsUrl) diff --git a/plugins/login/src/index.ts b/plugins/login/src/index.ts index 24ec83d30c..ebcda0d571 100644 --- a/plugins/login/src/index.ts +++ b/plugins/login/src/index.ts @@ -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>, - GetEndpoint: '' as Resource<() => Promise> + GetWorkspaces: '' as Resource<() => Promise> } })