From 496535f3ec06bb82ecb5d874470e5a91272cc46d Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Mon, 3 Mar 2025 13:32:33 +0700 Subject: [PATCH] Merge fixes Signed-off-by: Andrey Sobolev --- plugins/guest-resources/src/connect.ts | 14 +++++++------- plugins/login-resources/src/utils.ts | 10 +++------- server/account/src/__tests__/token.test.ts | 9 ++++++--- server/account/src/operations.ts | 9 ++++++--- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/plugins/guest-resources/src/connect.ts b/plugins/guest-resources/src/connect.ts index b4e90f41e1..307be974c5 100644 --- a/plugins/guest-resources/src/connect.ts +++ b/plugins/guest-resources/src/connect.ts @@ -1,18 +1,18 @@ import { Analytics } from '@hcengineering/analytics' import client from '@hcengineering/client' +import { setCurrentEmployee, type Employee } from '@hcengineering/contact' import core, { - type Account, ClientConnectEvent, concatLink, setCurrentAccount, versionToString, + type Account, type Client, - type Version, + type PersonId, type Ref, - type PersonId + type Version } from '@hcengineering/core' -import { setCurrentEmployee, type Employee } from '@hcengineering/contact' -import login, { loginId } from '@hcengineering/login' +import login from '@hcengineering/login' import { getMetadata, getResource, setMetadata } from '@hcengineering/platform' import presentation, { loadServerConfig, @@ -21,9 +21,9 @@ import presentation, { setPresentationCookie, upgradeDownloadProgress } from '@hcengineering/presentation' -import { desktopPlatform, getCurrentLocation, navigate } from '@hcengineering/ui' +import { desktopPlatform, getCurrentLocation } from '@hcengineering/ui' import { logOut } from '@hcengineering/workbench' -import { writable, get } from 'svelte/store' +import { get, writable } from 'svelte/store' export const versionError = writable(undefined) diff --git a/plugins/login-resources/src/utils.ts b/plugins/login-resources/src/utils.ts index 3f7d945c2c..d920cc77fd 100644 --- a/plugins/login-resources/src/utils.ts +++ b/plugins/login-resources/src/utils.ts @@ -300,17 +300,13 @@ export async function getAccount (doNavigate: boolean = true): Promise { it('should generate tokens', async () => { const extra: Record = { confirmed: 'true' } - const token = generateToken('mike@some.host', { name: '' }, extra, 'secret') + const token = generateToken('mike@some.host' as PersonUuid, '' as WorkspaceUuid, extra, 'secret') console.log(token) const decodedPayload = decodeTokenPayload(token) expect(decodedPayload).toEqual({ - confirmed: 'true', - email: 'mike@some.host', + extra: { + confirmed: 'true' + }, + account: 'mike@some.host', workspace: '' }) expect(decodedPayload.admin).not.toBe('true') diff --git a/server/account/src/operations.ts b/server/account/src/operations.ts index f0f65b2214..7450f01e99 100644 --- a/server/account/src/operations.ts +++ b/server/account/src/operations.ts @@ -413,10 +413,13 @@ export async function createInviteLink ( } // TODO: Temporary solution to prevent spam using sendInvite -const invitesSend = new Map() +} +>() export async function sendInvite ( ctx: MeasureContext, @@ -460,7 +463,7 @@ function checkRateLimit (email: string, workspaceName: string): void { if (lastInvites !== undefined) { lastInvites.totalSend++ lastInvites.lastSend = now - if (lastInvites.totalSend > 5 && (now - lastInvites.lastSend) < 60 * 1000) { + if (lastInvites.totalSend > 5 && now - lastInvites.lastSend < 60 * 1000) { // Less 60 seconds between invites throw new PlatformError( new Status(Severity.ERROR, platform.status.WorkspaceRateLimit, { workspace: workspaceName })