client passwords
Deploy / deploy (push) Successful in 2m57s

This commit is contained in:
twotalesanimation
2026-06-12 12:37:57 +02:00
parent 5bfaf49fa1
commit 23f0ceca3f
13 changed files with 377 additions and 74 deletions
+8 -1
View File
@@ -2,6 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/auth";
import { db } from "@/lib/db";
import { addDays } from "date-fns";
import bcrypt from "bcryptjs";
export async function GET(req: NextRequest) {
const session = await auth();
@@ -32,7 +33,7 @@ export async function POST(req: NextRequest) {
}
const body = await req.json();
const { projectId, label, email, expiresInDays = 30 } = body;
const { projectId, label, email, expiresInDays = 30, password } = body;
if (!projectId) {
return NextResponse.json({ error: "projectId is required" }, { status: 400 });
@@ -43,11 +44,17 @@ export async function POST(req: NextRequest) {
return NextResponse.json({ error: "Project not found" }, { status: 404 });
}
const passwordHash =
password && typeof password === "string" && password.length > 0
? await bcrypt.hash(password, 12)
: null;
const reviewSession = await db.reviewSession.create({
data: {
projectId,
label: label || `Review — ${project.name}`,
email: email || null,
passwordHash,
expiresAt: addDays(new Date(), expiresInDays),
},
});