mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Wrap verification code deletion and sync recording in a transaction
Ensures recordExternalDbSyncDeletion and verificationCode.delete are atomic, consistent with all other deletion helpers in the codebase.
This commit is contained in:
parent
60e9b8685a
commit
2971b655ff
@ -277,25 +277,27 @@ export function createVerificationCodeHandler<
|
||||
const { project, branchId } = parseProjectBranchCombo(revokeOptions);
|
||||
const tenancy = await getSoleTenancyFromProjectBranch(project.id, branchId);
|
||||
|
||||
// Record deletion for external DB sync if this is a TEAM_INVITATION code
|
||||
if (options.type === 'TEAM_INVITATION') {
|
||||
await recordExternalDbSyncDeletion(globalPrismaClient, {
|
||||
tableName: "VerificationCode_TEAM_INVITATION",
|
||||
tenancyId: tenancy.id,
|
||||
verificationCodeProjectId: project.id,
|
||||
verificationCodeBranchId: branchId,
|
||||
verificationCodeId: revokeOptions.id,
|
||||
});
|
||||
}
|
||||
await globalPrismaClient.$transaction(async (tx) => {
|
||||
// Record deletion for external DB sync if this is a TEAM_INVITATION code
|
||||
if (options.type === 'TEAM_INVITATION') {
|
||||
await recordExternalDbSyncDeletion(tx, {
|
||||
tableName: "VerificationCode_TEAM_INVITATION",
|
||||
tenancyId: tenancy.id,
|
||||
verificationCodeProjectId: project.id,
|
||||
verificationCodeBranchId: branchId,
|
||||
verificationCodeId: revokeOptions.id,
|
||||
});
|
||||
}
|
||||
|
||||
await globalPrismaClient.verificationCode.delete({
|
||||
where: {
|
||||
projectId_branchId_id: {
|
||||
projectId: project.id,
|
||||
branchId,
|
||||
id: revokeOptions.id,
|
||||
await tx.verificationCode.delete({
|
||||
where: {
|
||||
projectId_branchId_id: {
|
||||
projectId: project.id,
|
||||
branchId,
|
||||
id: revokeOptions.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
async validateCode(tenancyIdAndCode: string) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user