Update better-auth dependency to version 1.2.8 and enhance license key validation in the API to require at least one of enableEnterpriseFeatures or licenseKey.

This commit is contained in:
Mauricio Siu
2026-01-28 22:50:10 -06:00
parent 0c299a3807
commit 709ffddd4f
4 changed files with 22 additions and 15 deletions

View File

@@ -35,15 +35,22 @@ export const licenseKeyRouter = createTRPCRouter({
.mutation(async ({ ctx, input }) => {
const currentUserId = ctx.user.id;
if (
input.enableEnterpriseFeatures === undefined &&
input.licenseKey === undefined
) {
throw new TRPCError({
code: "BAD_REQUEST",
message:
"At least one of enableEnterpriseFeatures or licenseKey must be provided",
});
}
await db
.update(user)
.set({
...(input.enableEnterpriseFeatures === undefined
? {}
: { enableEnterpriseFeatures: input.enableEnterpriseFeatures }),
...(input.licenseKey === undefined
? {}
: { licenseKey: input.licenseKey }),
// enableEnterpriseFeatures: input.enableEnterpriseFeatures ?? false,
licenseKey: input.licenseKey ?? "",
})
.where(eq(user.id, currentUserId));