mirror of
https://github.com/documenso/documenso.git
synced 2026-07-11 05:25:08 +10:00
138d663c25
Merge origin/main into feat/external-2fa-codes. Resolve formatting conflicts caused by biome rollout; preserve both feature streams: PR's external 2FA token + signing-session 2FA proof additions plus main's RateLimit/RecipientExpired/signingReminders/date-auto-insert. In complete-document-with-token.ts, drop the duplicate early field-fetching block introduced when main moved that logic later with date auto-insert support; keep the EXTERNAL_TWO_FACTOR_AUTH check using derivedRecipientActionAuth.
47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import { prisma } from '@documenso/prisma';
|
|
import { UserSecurityAuditLogType } from '@prisma/client';
|
|
|
|
import type { RequestMetadata } from '../../universal/extract-request-metadata';
|
|
|
|
export interface UpdateAuthenticatorsOptions {
|
|
userId: number;
|
|
passkeyId: string;
|
|
name: string;
|
|
requestMetadata?: RequestMetadata;
|
|
}
|
|
|
|
export const updatePasskey = async ({ userId, passkeyId, name, requestMetadata }: UpdateAuthenticatorsOptions) => {
|
|
const passkey = await prisma.passkey.findFirstOrThrow({
|
|
where: {
|
|
id: passkeyId,
|
|
userId,
|
|
},
|
|
});
|
|
|
|
if (passkey.name === name) {
|
|
return;
|
|
}
|
|
|
|
await prisma.$transaction(async (tx) => {
|
|
await tx.passkey.update({
|
|
where: {
|
|
id: passkeyId,
|
|
userId,
|
|
},
|
|
data: {
|
|
name,
|
|
updatedAt: new Date(),
|
|
},
|
|
});
|
|
|
|
await tx.userSecurityAuditLog.create({
|
|
data: {
|
|
userId,
|
|
type: UserSecurityAuditLogType.PASSKEY_UPDATED,
|
|
userAgent: requestMetadata?.userAgent,
|
|
ipAddress: requestMetadata?.ipAddress,
|
|
},
|
|
});
|
|
});
|
|
};
|