mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-20 22:43:52 +00:00
add deleted mark for social ids (#8446)
Signed-off-by: Nikolay Chunosov <Chunosov.N@gmail.com>
This commit is contained in:
parent
0085c5aa42
commit
46446c5737
@ -20,8 +20,8 @@
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { getAccountClient } from '../utils'
|
||||
import { IntlString, translateCB } from '@hcengineering/platform'
|
||||
import contact, { getCurrentEmployee, SocialIdentity } from '@hcengineering/contact'
|
||||
import { buildSocialIdString, Ref, SocialIdType } from '@hcengineering/core'
|
||||
import contact, { getCurrentEmployee, SocialIdentityRef } from '@hcengineering/contact'
|
||||
import { buildSocialIdString, SocialIdType } from '@hcengineering/core'
|
||||
|
||||
export let mailboxOptions: MailboxOptions
|
||||
|
||||
@ -58,7 +58,7 @@
|
||||
value: mailbox,
|
||||
verifiedOn: Date.now()
|
||||
},
|
||||
socialId as any as Ref<SocialIdentity>
|
||||
socialId as SocialIdentityRef
|
||||
)
|
||||
await client.addCollection(
|
||||
contact.class.Channel,
|
||||
|
@ -645,7 +645,8 @@ export class PostgresAccountDB implements AccountDB {
|
||||
this.getV2Migration3(),
|
||||
this.getV3Migration(),
|
||||
this.getV4Migration(),
|
||||
this.getV4Migration1()
|
||||
this.getV4Migration1(),
|
||||
this.getV5Migration()
|
||||
]
|
||||
}
|
||||
|
||||
@ -890,4 +891,14 @@ export class PostgresAccountDB implements AccountDB {
|
||||
`
|
||||
]
|
||||
}
|
||||
|
||||
private getV5Migration (): [string, string] {
|
||||
return [
|
||||
'account_db_v5_social_id_is_deleted',
|
||||
`
|
||||
ALTER TABLE ${this.ns}.social_id
|
||||
ADD COLUMN IF NOT EXISTS is_deleted BOOL NOT NULL DEFAULT FALSE;
|
||||
`
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,8 @@ import {
|
||||
normalizeValue,
|
||||
isEmail,
|
||||
generatePassword,
|
||||
addSocialId
|
||||
addSocialId,
|
||||
releaseSocialId
|
||||
} from './utils'
|
||||
|
||||
// Move to config?
|
||||
@ -2063,12 +2064,7 @@ async function createMailbox (
|
||||
|
||||
await db.mailbox.insertOne({ accountUuid: account, mailbox })
|
||||
await db.mailboxSecret.insertOne({ mailbox, secret: generatePassword() })
|
||||
const socialId: PersonId = await db.socialId.insertOne({
|
||||
personUuid: account,
|
||||
type: SocialIdType.EMAIL,
|
||||
value: mailbox,
|
||||
verifiedOn: Date.now()
|
||||
})
|
||||
const socialId = await addSocialId(db, account, SocialIdType.EMAIL, mailbox, true)
|
||||
ctx.info('Mailbox created', { mailbox, account, socialId })
|
||||
return { mailbox, socialId }
|
||||
}
|
||||
@ -2123,18 +2119,6 @@ export async function addSocialIdToPerson (
|
||||
return await addSocialId(db, person, type, value, confirmed)
|
||||
}
|
||||
|
||||
async function releaseSocialId (
|
||||
db: AccountDB,
|
||||
personUuid: PersonUuid,
|
||||
type: SocialIdType,
|
||||
value: string
|
||||
): Promise<void> {
|
||||
const socialIds = await db.socialId.find({ personUuid, type, value })
|
||||
for (const socialId of socialIds) {
|
||||
await db.socialId.updateOne({ _id: socialId._id }, { value: `${socialId.value}#${socialId._id}` })
|
||||
}
|
||||
}
|
||||
|
||||
export type AccountMethods =
|
||||
| 'login'
|
||||
| 'loginOtp'
|
||||
|
@ -46,6 +46,7 @@ export interface SocialId extends SocialIdBase {
|
||||
personUuid: PersonUuid
|
||||
createdOn?: Timestamp
|
||||
verifiedOn?: Timestamp
|
||||
isDeleted?: boolean
|
||||
}
|
||||
|
||||
export interface Account {
|
||||
|
@ -1310,6 +1310,18 @@ export async function addSocialId (
|
||||
return await db.socialId.insertOne(newSocialId)
|
||||
}
|
||||
|
||||
export async function releaseSocialId (
|
||||
db: AccountDB,
|
||||
personUuid: PersonUuid,
|
||||
type: SocialIdType,
|
||||
value: string
|
||||
): Promise<void> {
|
||||
const socialIds = await db.socialId.find({ personUuid, type, value })
|
||||
for (const socialId of socialIds) {
|
||||
await db.socialId.updateOne({ _id: socialId._id }, { value: `${socialId.value}#${socialId._id}`, isDeleted: true })
|
||||
}
|
||||
}
|
||||
|
||||
export async function getWorkspaceRole (
|
||||
db: AccountDB,
|
||||
account: PersonUuid,
|
||||
|
@ -18,11 +18,10 @@ import {
|
||||
generateId,
|
||||
PersonId,
|
||||
PersonUuid,
|
||||
Ref,
|
||||
SocialIdType,
|
||||
TxOperations
|
||||
} from '@hcengineering/core'
|
||||
import contact, { AvatarType, combineName, SocialIdentity } from '@hcengineering/contact'
|
||||
import contact, { AvatarType, combineName, SocialIdentityRef } from '@hcengineering/contact'
|
||||
import { AccountClient } from '@hcengineering/account-client'
|
||||
|
||||
export async function ensureGlobalPerson (
|
||||
@ -100,7 +99,7 @@ export async function ensureLocalPerson (
|
||||
type: SocialIdType.EMAIL,
|
||||
value: email
|
||||
},
|
||||
personId as any as Ref<SocialIdentity>
|
||||
personId as SocialIdentityRef
|
||||
)
|
||||
ctx.info('Created local socialId', { mailId, personUuid, email })
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user