diff --git a/server/account/src/__tests__/postgres.test.ts b/server/account/src/__tests__/postgres.test.ts index cbfe8131a4..4e744b780e 100644 --- a/server/account/src/__tests__/postgres.test.ts +++ b/server/account/src/__tests__/postgres.test.ts @@ -244,6 +244,7 @@ describe('AccountPostgresDbCollection', () => { a.uuid, a.timezone, a.locale, + a.automatic, p.hash, p.salt FROM global_account.account as a diff --git a/server/account/src/collections/postgres.ts b/server/account/src/collections/postgres.ts index a942d67f9c..c098a9d73b 100644 --- a/server/account/src/collections/postgres.ts +++ b/server/account/src/collections/postgres.ts @@ -316,6 +316,7 @@ export class AccountPostgresDbCollection a.uuid, a.timezone, a.locale, + a.automatic, p.hash, p.salt FROM ${this.getTableName()} as a diff --git a/server/account/src/operations.ts b/server/account/src/operations.ts index 9209979d36..ccd06f2ea6 100644 --- a/server/account/src/operations.ts +++ b/server/account/src/operations.ts @@ -766,27 +766,29 @@ export async function checkAutoJoin ( if (emailSocialId != null) { const targetAccount = await getAccount(db, emailSocialId.personUuid) if (targetAccount != null) { - if (token == null) { - // Login required - const person = await db.person.findOne({ uuid: targetAccount.uuid }) + if (targetAccount.automatic == null || !targetAccount.automatic) { + if (token == null) { + // Login required + const person = await db.person.findOne({ uuid: targetAccount.uuid }) - return { - workspace: workspace.uuid, - name: person == null ? '' : getPersonName(person), - email: normalizedEmail + return { + workspace: workspace.uuid, + name: person == null ? '' : getPersonName(person), + email: normalizedEmail + } } - } - const { account: callerAccount } = decodeTokenVerbose(ctx, token) + const { account: callerAccount } = decodeTokenVerbose(ctx, token) - if (callerAccount !== targetAccount.uuid) { - // Login with target email required - const person = await db.person.findOne({ uuid: targetAccount.uuid }) + if (callerAccount !== targetAccount.uuid) { + // Login with target email required + const person = await db.person.findOne({ uuid: targetAccount.uuid }) - return { - workspace: workspace.uuid, - name: person == null ? '' : getPersonName(person), - email: normalizedEmail + return { + workspace: workspace.uuid, + name: person == null ? '' : getPersonName(person), + email: normalizedEmail + } } }