fix onboarding

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-03-13 11:47:27 +01:00
parent 996702437f
commit cfa1d9ab46
3 changed files with 12 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ import { createTRPCRouter, protectedProcedure } from '@/server/api/trpc';
import { db } from '@/server/db';
import { z } from 'zod';
import { hashPassword } from '@openpanel/common';
import { hashPassword, stripTrailingSlash } from '@openpanel/common';
export const clientRouter = createTRPCRouter({
list: protectedProcedure
@@ -71,7 +71,7 @@ export const clientRouter = createTRPCRouter({
project_id: input.projectId,
name: input.name,
secret: input.cors ? null : await hashPassword(secret),
cors: input.cors || undefined,
cors: input.cors ? stripTrailingSlash(input.cors) : '*',
},
});

View File

@@ -3,7 +3,7 @@ import { createTRPCRouter, protectedProcedure } from '@/server/api/trpc';
import { clerkClient } from '@clerk/nextjs';
import { z } from 'zod';
import { hashPassword } from '@openpanel/common';
import { hashPassword, stripTrailingSlash } from '@openpanel/common';
import { db } from '@openpanel/db';
export const onboardingRouter = createTRPCRouter({
@@ -35,7 +35,7 @@ export const onboardingRouter = createTRPCRouter({
name: `${project.name} Client`,
organization_slug: org.slug,
project_id: project.id,
cors: input.cors ?? '*',
cors: input.cors ? stripTrailingSlash(input.cors) : '*',
secret: input.cors ? null : await hashPassword(secret),
},
});
@@ -43,7 +43,7 @@ export const onboardingRouter = createTRPCRouter({
return {
client: {
...client,
secret,
secret: input.cors ? null : secret,
},
project,
organization: org,