diff --git a/apps/api/src/controllers/v0/admin/create-user.ts b/apps/api/src/controllers/v0/admin/create-user.ts index 61a683602..2d0936d86 100644 --- a/apps/api/src/controllers/v0/admin/create-user.ts +++ b/apps/api/src/controllers/v0/admin/create-user.ts @@ -3,6 +3,7 @@ import { Request, Response } from "express"; import { supabase_service } from "../../../services/supabase"; import crypto from "crypto"; import { z } from "zod"; +import { apiKeyToFcApiKey } from "../../../lib/parseApi"; async function addCoupon(teamId: string, integration: any) { if (!integration.coupon_credits) { @@ -259,7 +260,7 @@ export async function createUserController(req: Request, res: Response) { } return res.status(200).json({ - apiKey, + apiKey: apiKeyToFcApiKey(apiKey), alreadyExisted, }); } catch (error) { diff --git a/apps/api/src/lib/parseApi.ts b/apps/api/src/lib/parseApi.ts index 4479d44d1..153d75f0b 100644 --- a/apps/api/src/lib/parseApi.ts +++ b/apps/api/src/lib/parseApi.ts @@ -12,3 +12,11 @@ export function parseApi(api: string) { .replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5"); return uuid; } + +export function apiKeyToFcApiKey(apiKey: string | null | undefined) { + if (!apiKey) { + return null; + } + const uuidWithoutDashes = apiKey.replace(/-/g, ""); + return `fc-${uuidWithoutDashes}`; +}