The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
chore: Add logo field to OAuth app schema and update related code
Kiran K321b00a57eb6
diff --git a/apps/web/app/api/oauth-apps/[clientId]/route.ts b/apps/web/app/api/oauth-apps/[clientId]/route.tsindex fe90b00303..f22c74a36e 100644--- a/apps/web/app/api/oauth-apps/[clientId]/route.ts+++ b/apps/web/app/api/oauth-apps/[clientId]/route.ts@@ -32,7 +32,7 @@ export const GET = withWorkspace(// PATCH /api/oauth-apps/[clientId] – update an OAuth appexport const PATCH = withWorkspace(async ({ req, params, workspace }) => {- const { name, developer, website, redirectUri } =+ const { name, developer, website, redirectUri, logo } =updateOAuthAppSchema.parse(await parseRequestBody(req));const app = await prisma.oAuthApp.update({@@ -45,6 +45,7 @@ export const PATCH = withWorkspace(...(developer && { developer }),...(website && { website }),...(redirectUri && { redirectUri }),+ ...(logo && { logo }),},});diff --git a/apps/web/app/api/oauth-apps/route.ts b/apps/web/app/api/oauth-apps/route.tsindex 475157fa94..d55f54db54 100644--- a/apps/web/app/api/oauth-apps/route.ts+++ b/apps/web/app/api/oauth-apps/route.ts@@ -11,10 +11,10 @@ import { nanoid } from "@dub/utils";import { NextResponse } from "next/server";import { z } from "zod";-// POST /api/oauth-apps - create a new OAuth apps+// POST /api/oauth-apps - create a new OAuth appexport const POST = withWorkspace(async ({ req, workspace, session }) => {- const { name, developer, website, redirectUri } =+ const { name, developer, website, redirectUri, logo } =createOAuthAppSchema.parse(await parseRequestBody(req));const clientSecret = `${OAUTH_CLIENT_SECRET_PREFIX}${nanoid(OAUTH_CLIENT_SECRET_LENGTH)}`;@@ -26,17 +26,13 @@ export const POST = withWorkspace(developer,website,redirectUri,+ logo,clientId: nanoid(OAUTH_CLIENT_ID_LENGTH),clientSecretHashed: await hashToken(clientSecret),createdBy: session.user.id,},});- console.log({- ...oAuthAppSchema.parse(client),- clientSecret,- });-return NextResponse.json({...oAuthAppSchema.parse(client),diff --git a/apps/web/app/app.dub.co/(auth)/oauth/authorize/page.tsx b/apps/web/app/app.dub.co/(auth)/oauth/authorize/page.tsxindex 9c6363f28c..cb7a513774 100644--- a/apps/web/app/app.dub.co/(auth)/oauth/authorize/page.tsx+++ b/apps/web/app/app.dub.co/(auth)/oauth/authorize/page.tsx@@ -2,7 +2,7 @@ import { vaidateAuthorizeRequest } from "@/lib/api/oauth/actions";import { getSession } from "@/lib/auth";import z from "@/lib/zod";import { authorizeRequestSchema } from "@/lib/zod/schemas/oauth";-import { Logo } from "@dub/ui";+import { BlurImage, Logo } from "@dub/ui";import { HOME_DOMAIN, constructMetadata } from "@dub/utils";import { ArrowLeftRight } from "lucide-react";import { redirect } from "next/navigation";@@ -17,6 +17,7 @@ export const metadata = constructMetadata({noIndex: true,});+// OAuth app consent pageexport default async function Authorize({searchParams,}: {@@ -46,7 +47,17 @@ export default async function Authorize({<div className="flex flex-col items-center justify-center space-y-6 border-b border-gray-200 bg-white px-4 py-6 pt-8 text-center sm:px-16"><div className="flex items-center gap-3"><a href={oAuthApp.website} target="_blank" rel="noreferrer">- <Logo className="h-14 w-14" />+ {oAuthApp.logo ? (+ <BlurImage+ src={oAuthApp.logo}+ alt={`Logo for ${oAuthApp.name}`}+ className="h-14 w-14 rounded-full border border-gray-200"+ width={20}+ height={20}+ />+ ) : (+ <Logo className="h-14 w-14" />+ )}</a><ArrowLeftRight className="h-6 w-6 text-gray-500" /><a href={HOME_DOMAIN} target="_blank" rel="noreferrer">diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/page-client.tsxindex 39777af1a2..14dd1048e3 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/oauth-apps/page-client.tsx@@ -7,7 +7,13 @@ import { useDeleteAppModal } from "@/ui/modals/delete-oauth-app-modal";import { useAppCreatedModal } from "@/ui/modals/oauth-app-created-modal";import EmptyState from "@/ui/shared/empty-state";import { CheckCircleFill, Delete } from "@/ui/shared/icons";-import { Button, LoadingSpinner, Popover, TokenAvatar } from "@dub/ui";+import {+ BlurImage,+ Button,+ LoadingSpinner,+ Popover,+ TokenAvatar,+} from "@dub/ui";import { Key } from "@dub/ui/src/icons";import { fetcher } from "@dub/utils";import { Copy, Edit3, MoreVertical } from "lucide-react";@@ -119,7 +125,17 @@ const AppRow = (app: OAuthAppProps) => {<DeleteAppModal /><div className="relative grid grid-cols-5 items-center px-5 py-3 sm:px-10"><div className="col-span-3 flex items-center space-x-3">- <TokenAvatar id={app.clientId} />+ {app.logo ? (+ <BlurImage+ src={app.logo}+ alt={`Logo for ${app.name}`}+ className="h-10 w-10 rounded-full border border-gray-200"+ width={20}+ height={20}+ />+ ) : (+ <TokenAvatar id={app.clientId} />+ )}<div className="flex flex-col space-y-px"><p className="font-semibold text-gray-700">{app.name}</p><div className="flex items-center gap-x-2">diff --git a/apps/web/lib/zod/schemas/oauth.ts b/apps/web/lib/zod/schemas/oauth.tsindex 4c35b2ff59..a07ea02400 100644--- a/apps/web/lib/zod/schemas/oauth.ts+++ b/apps/web/lib/zod/schemas/oauth.ts@@ -8,6 +8,7 @@ export const oAuthAppSchema = z.object({developer: z.string(),website: z.string(),redirectUri: z.string(),+ logo: z.string().nullable(),});export const createOAuthAppSchema = z.object({@@ -19,6 +20,13 @@ export const createOAuthAppSchema = z.object({message: "website must be a valid URL",}).max(255),+ logo: z+ .string()+ .url({+ message: "Please provide a valid URL for the logo",+ })+ .max(255)+ .nullable(),redirectUri: z.string().url({ message: "redirect_uri must be a valid URL" })diff --git a/apps/web/ui/modals/add-edit-oauth-app-modal.tsx b/apps/web/ui/modals/add-edit-oauth-app-modal.tsxindex 5208a872e0..7871cecd7a 100644--- a/apps/web/ui/modals/add-edit-oauth-app-modal.tsx+++ b/apps/web/ui/modals/add-edit-oauth-app-modal.tsx@@ -25,6 +25,7 @@ const newApp: OAuthAppProps = {website: "",clientId: "",redirectUri: "",+ logo: null,};function AddEditAppModal({@@ -39,7 +40,7 @@ function AddEditAppModal({onAppCreated?: (App: OAuthAppProps) => void;}) {const [saving, setSaving] = useState(false);- const { id: workspaceId, logo, slug } = useWorkspace();+ const { id: workspaceId, logo: workspaceLogo, slug } = useWorkspace();const [data, setData] = useState<OAuthAppProps>(app || newApp);// Determine the endpoint@@ -85,7 +86,7 @@ function AddEditAppModal({}};- const { name, developer, website, redirectUri } = data;+ const { name, developer, website, redirectUri, logo } = data;const buttonDisabled = !name || !developer || !website || !redirectUri;return (@@ -96,9 +97,9 @@ function AddEditAppModal({className="scrollbar-hide h-fit max-h-[95vh] overflow-auto"><div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">- {logo ? (+ {workspaceLogo ? (<BlurImage- src={logo}+ src={workspaceLogo}alt={`Logo for ${slug}`}className="h-10 w-10 rounded-full border border-gray-200"width={20}@@ -173,6 +174,22 @@ function AddEditAppModal({</div></div>+ <div>+ <label htmlFor="logo" className="flex items-center space-x-2">+ <h2 className="text-sm font-medium text-gray-900">Logo URL</h2>+ <InfoTooltip content="URL to your application's logo" />+ </label>+ <div className="relative mt-2 rounded-md shadow-sm">+ <input+ className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-400 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"+ type="url"+ value={logo || ""}+ onChange={(e) => setData({ ...data, logo: e.target.value })}+ placeholder="https://acme.com/logo.png"+ />+ </div>+ </div>+<div><labelhtmlFor="redirectUri"