feature(dashboard): actually add password production to overviews

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-01-21 15:19:50 +00:00
parent 08bfff94cf
commit f216a7b9c5
7 changed files with 192 additions and 39 deletions

View File

@@ -3,6 +3,7 @@ import ShortUniqueId from 'short-unique-id';
import { db } from '@openpanel/db';
import { zShareOverview } from '@openpanel/validation';
import { hashPassword } from '@openpanel/auth';
import { createTRPCRouter, protectedProcedure } from '../trpc';
const uid = new ShortUniqueId({ length: 6 });
@@ -11,6 +12,10 @@ export const shareRouter = createTRPCRouter({
shareOverview: protectedProcedure
.input(zShareOverview)
.mutation(async ({ input }) => {
const passwordHash = input.password
? await hashPassword(input.password)
: null;
return db.shareOverview.upsert({
where: {
projectId: input.projectId,
@@ -20,11 +25,11 @@ export const shareRouter = createTRPCRouter({
organizationId: input.organizationId,
projectId: input.projectId,
public: input.public,
password: input.password || null,
password: passwordHash,
},
update: {
public: input.public,
password: input.password,
password: passwordHash,
},
});
}),