Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-06-08 11:34:29 +06:00 committed by GitHub
parent de1dc72c99
commit c8bc249778
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,6 +74,7 @@ const accountPlugin = plugin(accountId, {
WorkspaceNotFound: '' as StatusCode<{ workspace: string }>,
InvalidPassword: '' as StatusCode<{ account: string }>,
AccountAlreadyExists: '' as StatusCode<{ account: string }>,
AccountAlreadyConfirmed: '' as StatusCode<{ account: string }>,
AccountWasMerged: '' as StatusCode<{ account: string }>,
WorkspaceAlreadyExists: '' as StatusCode<{ workspace: string }>,
ProductIdMismatch: '' as StatusCode<{ productId: string }>
@ -374,6 +375,11 @@ export async function confirmEmail (db: Db, email: string): Promise<Account> {
if (account === null) {
throw new PlatformError(new Status(Severity.ERROR, accountPlugin.status.AccountNotFound, { account: accountId }))
}
if (account.confirmed === true) {
throw new PlatformError(
new Status(Severity.ERROR, accountPlugin.status.AccountAlreadyConfirmed, { account: accountId })
)
}
await db.collection(ACCOUNT_COLLECTION).updateOne({ _id: account._id }, { $set: { confirmed: true } })
account.confirmed = true
@ -568,14 +574,16 @@ export async function createWorkspace (
productId
})
.then((e) => e.insertedId.toHexString())
await initModel(getTransactor(), getWorkspaceId(workspace, productId), txes, migrationOperation)
const initWS = getMetadata(toolPlugin.metadata.InitWorkspace)
if (initWS !== undefined) {
if ((await getWorkspace(db, productId, initWS)) !== null) {
await initModel(getTransactor(), getWorkspaceId(workspace, productId), txes, [])
await cloneWorkspace(getTransactor(), getWorkspaceId(initWS, productId), getWorkspaceId(workspace, productId))
await upgradeModel(getTransactor(), getWorkspaceId(workspace, productId), txes, migrationOperation)
return result
}
}
await initModel(getTransactor(), getWorkspaceId(workspace, productId), txes, migrationOperation)
return result
}