Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backend/src/api/public/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/HttpError'
'409':
description: Identity is already verified on another member.
content:
application/json:
schema:
$ref: '#/components/schemas/HttpError'
Comment thread
skwowet marked this conversation as resolved.

# ──────────────────────────────────────────────
# Maintainer Roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
memberUnmergeAction,
memberVerifyIdentityAction,
} from '@crowd/audit-logs'
import { InternalError, NotFoundError } from '@crowd/common'
import { ConflictError, InternalError, NotFoundError } from '@crowd/common'
import {
invalidateMemberQueryCache,
prepareMemberUnmerge,
Expand All @@ -15,6 +15,7 @@ import {
} from '@crowd/common_services'
import {
MemberField,
checkMemberIdentityExistence,
deleteMemberIdentity,
findMemberById,
findMemberIdentityById,
Expand Down Expand Up @@ -85,6 +86,19 @@ export async function verifyMemberIdentity(req: Request, res: Response): Promise
captureOldState(identity)

await qx.tx(async (tx) => {
if (verified) {
const existingIdentities = await checkMemberIdentityExistence(
tx,
identity.value,
identity.platform,
identity.type,
)

Comment thread
skwowet marked this conversation as resolved.
Outdated
if (existingIdentities.some((i) => i.memberId !== memberId && i.verified)) {
throw new ConflictError('Identity already verified on another member')
}
}

updatedIdentity = await updateMemberIdentity(tx, memberId, identityId, {
verified,
Comment thread
skwowet marked this conversation as resolved.
Outdated
verifiedBy,
Expand Down
Loading