mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-21 15:02:13 +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 { createEventDispatcher } from 'svelte'
|
||||||
import { getAccountClient } from '../utils'
|
import { getAccountClient } from '../utils'
|
||||||
import { IntlString, translateCB } from '@hcengineering/platform'
|
import { IntlString, translateCB } from '@hcengineering/platform'
|
||||||
import contact, { getCurrentEmployee, SocialIdentity } from '@hcengineering/contact'
|
import contact, { getCurrentEmployee, SocialIdentityRef } from '@hcengineering/contact'
|
||||||
import { buildSocialIdString, Ref, SocialIdType } from '@hcengineering/core'
|
import { buildSocialIdString, SocialIdType } from '@hcengineering/core'
|
||||||
|
|
||||||
export let mailboxOptions: MailboxOptions
|
export let mailboxOptions: MailboxOptions
|
||||||
|
|
||||||
@ -58,7 +58,7 @@
|
|||||||
value: mailbox,
|
value: mailbox,
|
||||||
verifiedOn: Date.now()
|
verifiedOn: Date.now()
|
||||||
},
|
},
|
||||||
socialId as any as Ref<SocialIdentity>
|
socialId as SocialIdentityRef
|
||||||
)
|
)
|
||||||
await client.addCollection(
|
await client.addCollection(
|
||||||
contact.class.Channel,
|
contact.class.Channel,
|
||||||
|
@ -645,7 +645,8 @@ export class PostgresAccountDB implements AccountDB {
|
|||||||
this.getV2Migration3(),
|
this.getV2Migration3(),
|
||||||
this.getV3Migration(),
|
this.getV3Migration(),
|
||||||
this.getV4Migration(),
|
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,
|
normalizeValue,
|
||||||
isEmail,
|
isEmail,
|
||||||
generatePassword,
|
generatePassword,
|
||||||
addSocialId
|
addSocialId,
|
||||||
|
releaseSocialId
|
||||||
} from './utils'
|
} from './utils'
|
||||||
|
|
||||||
// Move to config?
|
// Move to config?
|
||||||
@ -2063,12 +2064,7 @@ async function createMailbox (
|
|||||||
|
|
||||||
await db.mailbox.insertOne({ accountUuid: account, mailbox })
|
await db.mailbox.insertOne({ accountUuid: account, mailbox })
|
||||||
await db.mailboxSecret.insertOne({ mailbox, secret: generatePassword() })
|
await db.mailboxSecret.insertOne({ mailbox, secret: generatePassword() })
|
||||||
const socialId: PersonId = await db.socialId.insertOne({
|
const socialId = await addSocialId(db, account, SocialIdType.EMAIL, mailbox, true)
|
||||||
personUuid: account,
|
|
||||||
type: SocialIdType.EMAIL,
|
|
||||||
value: mailbox,
|
|
||||||
verifiedOn: Date.now()
|
|
||||||
})
|
|
||||||
ctx.info('Mailbox created', { mailbox, account, socialId })
|
ctx.info('Mailbox created', { mailbox, account, socialId })
|
||||||
return { mailbox, socialId }
|
return { mailbox, socialId }
|
||||||
}
|
}
|
||||||
@ -2123,18 +2119,6 @@ export async function addSocialIdToPerson (
|
|||||||
return await addSocialId(db, person, type, value, confirmed)
|
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 =
|
export type AccountMethods =
|
||||||
| 'login'
|
| 'login'
|
||||||
| 'loginOtp'
|
| 'loginOtp'
|
||||||
|
@ -46,6 +46,7 @@ export interface SocialId extends SocialIdBase {
|
|||||||
personUuid: PersonUuid
|
personUuid: PersonUuid
|
||||||
createdOn?: Timestamp
|
createdOn?: Timestamp
|
||||||
verifiedOn?: Timestamp
|
verifiedOn?: Timestamp
|
||||||
|
isDeleted?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Account {
|
export interface Account {
|
||||||
|
@ -1310,6 +1310,18 @@ export async function addSocialId (
|
|||||||
return await db.socialId.insertOne(newSocialId)
|
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 (
|
export async function getWorkspaceRole (
|
||||||
db: AccountDB,
|
db: AccountDB,
|
||||||
account: PersonUuid,
|
account: PersonUuid,
|
||||||
|
@ -18,11 +18,10 @@ import {
|
|||||||
generateId,
|
generateId,
|
||||||
PersonId,
|
PersonId,
|
||||||
PersonUuid,
|
PersonUuid,
|
||||||
Ref,
|
|
||||||
SocialIdType,
|
SocialIdType,
|
||||||
TxOperations
|
TxOperations
|
||||||
} from '@hcengineering/core'
|
} 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'
|
import { AccountClient } from '@hcengineering/account-client'
|
||||||
|
|
||||||
export async function ensureGlobalPerson (
|
export async function ensureGlobalPerson (
|
||||||
@ -100,7 +99,7 @@ export async function ensureLocalPerson (
|
|||||||
type: SocialIdType.EMAIL,
|
type: SocialIdType.EMAIL,
|
||||||
value: email
|
value: email
|
||||||
},
|
},
|
||||||
personId as any as Ref<SocialIdentity>
|
personId as SocialIdentityRef
|
||||||
)
|
)
|
||||||
ctx.info('Created local socialId', { mailId, personUuid, email })
|
ctx.info('Created local socialId', { mailId, personUuid, email })
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user