diff --git a/apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/users/page-client.tsx b/apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/users/page-client.tsx index c2f46cb40..2f9852a5f 100644 --- a/apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/users/page-client.tsx +++ b/apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/users/page-client.tsx @@ -10,6 +10,7 @@ import { PageLayout } from "../page-layout"; import { useAdminApp } from "../use-admin-app"; function CreateDialog(props: { + existingEmails: string[], open?: boolean, onOpenChange?: (open: boolean) => void, trigger?: React.ReactNode, @@ -17,7 +18,7 @@ function CreateDialog(props: { const adminApp = useAdminApp(); const formSchema = yup.object({ displayName: yup.string().optional(), - primaryEmail: yup.string().email().required(), + primaryEmail: yup.string().email().notOneOf(props.existingEmails, "Email already exists").required(), primaryEmailVerified: yup.boolean().optional(), password: yup.string().required(), }); @@ -56,7 +57,13 @@ export default function PageClient() { const allUsers = stackAdminApp.useUsers(); return ( - Create User} />}> + Create User} + existingEmails={allUsers.map(u => u.primaryEmail).filter(e => e !== null) as string[]} + />} + > {allUsers.length > 0 ? null : ( Congratulations on starting your project! Check the documentation to add your first users.