Harden demo access and restore clean checks

This commit is contained in:
2026-08-14 16:45:02 -04:00
parent 29d7b498ae
commit 66a53f25f2
10 changed files with 114 additions and 11 deletions
+3 -2
View File
@@ -6,6 +6,7 @@ import { TRPCError } from "@trpc/server";
import type { db } from "~/server/db";
import {
computeTrackedHours,
normalizeOptionalId,
resolveBillingDescription,
type ClockOutOutcome,
} from "~/lib/time-clock";
@@ -242,7 +243,7 @@ export const timeEntriesRouter = createTRPCRouter({
});
}
const clientId = input.clientId?.trim() || null;
const clientId = normalizeOptionalId(input.clientId);
let clientRecord: { defaultHourlyRate: number | null } | null = null;
if (clientId) {
const found = await ctx.db.query.clients.findFirst({
@@ -514,7 +515,7 @@ export const timeEntriesRouter = createTRPCRouter({
create: protectedProcedure
.input(createSchema)
.mutation(async ({ ctx, input }) => {
const clientId = input.clientId?.trim() || null;
const clientId = normalizeOptionalId(input.clientId);
if (clientId) {
const client = await ctx.db.query.clients.findFirst({
where: and(eq(clients.id, clientId), eq(clients.createdById, ctx.session.user.id)),