From d188eaec916c94d77b407e707c3c2fc9eb6c1cab Mon Sep 17 00:00:00 2001 From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> Date: Tue, 11 Jan 2022 19:35:21 +0600 Subject: [PATCH] Signup fix (#798) Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> --- common/config/rush/pnpm-lock.yaml | 8 +++-- dev/docker-compose.yaml | 2 ++ dev/prod/src/main-dev.ts | 19 ++++++------ dev/prod/src/main.ts | 5 ++-- dev/prod/src/platform.ts | 4 +-- plugins/login-assets/lang/en.json | 5 +++- .../src/components/SelectWorkspace.svelte | 17 +++++++++-- plugins/login-resources/src/plugin.ts | 5 +++- server/account/package.json | 6 ++-- server/account/src/index.ts | 29 ++++++++++--------- server/account/src/tool.ts | 7 +++-- 11 files changed, 71 insertions(+), 36 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 0f130afa7e..407fb10602 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -10653,13 +10653,14 @@ packages: dev: false file:projects/account.tgz: - resolution: {integrity: sha512-g8Jj5vatEBYxczIayNpyhAJypuGS17w8t4htZB0ljRlctQ9IQ69fMKfuVYDb8OTKMZuhuadDthRAqqsJevuxvA==, tarball: file:projects/account.tgz} + resolution: {integrity: sha512-/BBGpjzh87DsWYJmHFtYyTBH2FerxHMoGT3xQ4A5IHVtKmx2gTP5mdaY09h+vaNp+a4iTs5rqa7h+Y7l/5uX2w==, tarball: file:projects/account.tgz} name: '@rush-temp/account' version: 0.0.0 dependencies: '@rushstack/heft': 0.41.8 '@types/heft-jest': 1.0.2 '@types/minio': 7.0.11 + '@types/ws': 8.2.2 '@typescript-eslint/eslint-plugin': 5.7.0_c25e8c1f4f4f7aaed27aa6f9ce042237 '@typescript-eslint/parser': 5.7.0_eslint@7.32.0+typescript@4.5.4 eslint: 7.32.0 @@ -10672,8 +10673,11 @@ packages: mongodb: 4.2.2 prettier: 2.5.1 typescript: 4.5.4 + ws: 8.3.0 transitivePeerDependencies: + - bufferutil - supports-color + - utf-8-validate dev: false file:projects/activity-assets.tgz: @@ -10922,7 +10926,7 @@ packages: dev: false file:projects/contact-resources.tgz_096c09b0b673a57c275d9767a12070b1: - resolution: {integrity: sha512-4SUPVPcAFE83qvwymkwI7i+z0ioEgAmM+H08vsjXRkEeD0vOlRLD3tEBX+0W49mL93EZG0TUEPP8zPcl7wiiAg==, tarball: file:projects/contact-resources.tgz} + resolution: {integrity: sha512-5c2Hkvtnj+3t/r1Z+RFQuoxDwYm6ndTPCxFns6PK3SqCs/KfWREism8tiswJXrB2FNSQkb2CE7yvsftKZFcbPQ==, tarball: file:projects/contact-resources.tgz} id: file:projects/contact-resources.tgz name: '@rush-temp/contact-resources' version: 0.0.0 diff --git a/dev/docker-compose.yaml b/dev/docker-compose.yaml index c6bcc9e053..349aa0c1f5 100644 --- a/dev/docker-compose.yaml +++ b/dev/docker-compose.yaml @@ -42,6 +42,8 @@ services: image: anticrm/account links: - mongodb + - minio + - transactor ports: - 3000:3000 environment: diff --git a/dev/prod/src/main-dev.ts b/dev/prod/src/main-dev.ts index b069439be2..1f1406733e 100644 --- a/dev/prod/src/main-dev.ts +++ b/dev/prod/src/main-dev.ts @@ -18,13 +18,14 @@ import { createApp } from '@anticrm/ui' import { configurePlatform } from './platform' import { configurePlatformDev, configurePlatformDevServer } from './platform-dev' -configurePlatform() +configurePlatform().then(() => { + if (process.env.CLIENT_TYPE === 'dev') { + configurePlatformDev() + } + if (process.env.CLIENT_TYPE === 'dev-server') { + configurePlatformDevServer() + } + + createApp(document.body) +}) -if (process.env.CLIENT_TYPE === 'dev') { - configurePlatformDev() -} -if (process.env.CLIENT_TYPE === 'dev-server') { - configurePlatformDevServer() -} - -createApp(document.body) diff --git a/dev/prod/src/main.ts b/dev/prod/src/main.ts index 6901716185..4b586d4443 100644 --- a/dev/prod/src/main.ts +++ b/dev/prod/src/main.ts @@ -17,5 +17,6 @@ import { createApp } from '@anticrm/ui' import { configurePlatform } from './platform' -configurePlatform() -createApp(document.body) +configurePlatform().then(() => { + createApp(document.body) +}) diff --git a/dev/prod/src/platform.ts b/dev/prod/src/platform.ts index 214aff867f..2309e1de72 100644 --- a/dev/prod/src/platform.ts +++ b/dev/prod/src/platform.ts @@ -45,8 +45,8 @@ import '@anticrm/gmail-assets' import '@anticrm/workbench-assets' import { setMetadata } from '@anticrm/platform' -export function configurePlatform() { - fetch('/config.json').then(config => { +export async function configurePlatform() { + await fetch('/config.json').then(config => { config.json().then(value => { console.log('loading configuration', value) setMetadata(login.metadata.AccountsUrl, value.ACCOUNTS_URL) diff --git a/plugins/login-assets/lang/en.json b/plugins/login-assets/lang/en.json index c34e44d996..c063166fa4 100644 --- a/plugins/login-assets/lang/en.json +++ b/plugins/login-assets/lang/en.json @@ -22,6 +22,9 @@ "SelectWorkspace": "Select workspace", "Copy": "Copy", "Close": "Close", - "InviteDescription": "Share this link to invite other users" + "InviteDescription": "Share this link to invite other users", + "WantAnotherWorkspace": "Want to create another workspace?", + "ChangeAccount": "Change account", + "NotSeeingWorkspace": "Not seeing your workspace?" } } \ No newline at end of file diff --git a/plugins/login-resources/src/components/SelectWorkspace.svelte b/plugins/login-resources/src/components/SelectWorkspace.svelte index 1f40fda391..abd9192898 100644 --- a/plugins/login-resources/src/components/SelectWorkspace.svelte +++ b/plugins/login-resources/src/components/SelectWorkspace.svelte @@ -45,6 +45,13 @@ loc.path.length = 2 navigate(loc) } + + function changeAccount (): void { + const loc = getCurrentLocation() + loc.path[1] = 'login' + loc.path.length = 2 + navigate(loc) + }
@@ -72,8 +79,14 @@
{#if workspaces.length} {/if} {/await} diff --git a/plugins/login-resources/src/plugin.ts b/plugins/login-resources/src/plugin.ts index 0efe1b0b61..8c01b96c56 100644 --- a/plugins/login-resources/src/plugin.ts +++ b/plugins/login-resources/src/plugin.ts @@ -43,6 +43,9 @@ export default mergeIds(loginId, login, { DoNotHaveAnAccount: '' as IntlString, Copy: '' as IntlString, Close: '' as IntlString, - InviteDescription: '' as IntlString + InviteDescription: '' as IntlString, + WantAnotherWorkspace: '' as IntlString, + NotSeeingWorkspace: '' as IntlString, + ChangeAccount: '' as IntlString } }) diff --git a/server/account/package.json b/server/account/package.json index 2821a8a639..df74ef3975 100644 --- a/server/account/package.json +++ b/server/account/package.json @@ -24,7 +24,8 @@ "prettier": "^2.4.1", "@rushstack/heft": "^0.41.1", "typescript": "^4.3.5", - "@types/minio": "^7.0.10" + "@types/minio": "^7.0.10", + "@types/ws": "^8.2.1" }, "dependencies": { "mongodb": "^4.1.1", @@ -35,6 +36,7 @@ "@anticrm/contact": "~0.6.2", "@anticrm/client-resources": "~0.6.4", "@anticrm/client": "~0.6.1", - "jwt-simple": "~0.5.6" + "jwt-simple": "~0.5.6", + "ws": "^8.2.0" } } diff --git a/server/account/src/index.ts b/server/account/src/index.ts index 4e3b424a57..a67ce01755 100644 --- a/server/account/src/index.ts +++ b/server/account/src/index.ts @@ -379,22 +379,25 @@ export async function assignWorkspace (db: Db, email: string, workspace: string) async function createEmployeeAccount (account: Account, workspace: string): Promise { const connection = await connect(getEndpoint(), workspace, account.email) - const ops = new TxOperations(connection, core.account.System) + try { + const ops = new TxOperations(connection, core.account.System) - const name = combineName(account.first, account.last) + const name = combineName(account.first, account.last) - const employee = await ops.createDoc(contact.class.Employee, contact.space.Employee, { - name, - city: '', - channels: [] - }) + const employee = await ops.createDoc(contact.class.Employee, contact.space.Employee, { + name, + city: '', + channels: [] + }) - await ops.createDoc(contact.class.EmployeeAccount, core.space.Model, { - email: account.email, - employee, - name - }) - await connection.close() + await ops.createDoc(contact.class.EmployeeAccount, core.space.Model, { + email: account.email, + employee, + name + }) + } finally { + await connection.close() + } } /** diff --git a/server/account/src/tool.ts b/server/account/src/tool.ts index 2eda019222..d1396a3632 100644 --- a/server/account/src/tool.ts +++ b/server/account/src/tool.ts @@ -74,8 +74,11 @@ export async function initWorkspace (transactorUrl: string, dbName: string): Pro console.log('creating data...') const connection = await connect(transactorUrl, dbName) - await createDeps(connection) - await connection.close() + try { + await createDeps(connection) + } finally { + await connection.close() + } console.log('create minio bucket') if (!(await minio.bucketExists(dbName))) {