mirror of
https://github.com/documenso/documenso.git
synced 2026-07-20 23:13:34 +10:00
feat: certificate qrcode (#1755)
Adds document access tokens and QR code functionality to enable secure document sharing via URLs. It includes a new document access page that allows viewing and downloading documents through tokenized links.
This commit is contained in:
@@ -31,4 +31,38 @@ export const kyselyPrisma = remember('kyselyPrisma', () =>
|
||||
),
|
||||
);
|
||||
|
||||
export const prismaWithLogging = remember('prismaWithLogging', () => {
|
||||
const client = new PrismaClient({
|
||||
datasourceUrl: getDatabaseUrl(),
|
||||
log: [
|
||||
{
|
||||
emit: 'event',
|
||||
level: 'query',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
client.$on('query', (e) => {
|
||||
console.log('query:', e.query);
|
||||
console.log('params:', e.params);
|
||||
console.log('duration:', e.duration);
|
||||
|
||||
const params = JSON.parse(e.params) as unknown[];
|
||||
|
||||
const query = e.query.replace(/\$\d+/g, (match) => {
|
||||
const index = Number(match.replace('$', ''));
|
||||
|
||||
if (index > params.length) {
|
||||
return match;
|
||||
}
|
||||
|
||||
return String(params[index - 1]);
|
||||
});
|
||||
|
||||
console.log('formatted query:', query);
|
||||
});
|
||||
|
||||
return client;
|
||||
});
|
||||
|
||||
export { sql } from 'kysely';
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Document" ADD COLUMN "qrToken" TEXT;
|
||||
@@ -315,6 +315,7 @@ enum DocumentVisibility {
|
||||
/// @zod.import(["import { ZDocumentAuthOptionsSchema } from '@documenso/lib/types/document-auth';", "import { ZDocumentFormValuesSchema } from '@documenso/lib/types/document-form-values';"])
|
||||
model Document {
|
||||
id Int @id @default(autoincrement())
|
||||
qrToken String? /// @zod.string.describe("The token for viewing the document using the QR code on the certificate.")
|
||||
externalId String? /// @zod.string.describe("A custom external ID you can use to identify the document.")
|
||||
userId Int /// @zod.number.describe("The ID of the user that created this document.")
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
Reference in New Issue
Block a user