mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
added email duplication check on the dashboard
This commit is contained in:
parent
ec5c4c8afb
commit
1b8f1628e5
@ -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 (
|
||||
<PageLayout title="Users" actions={<CreateDialog trigger={<Button>Create User</Button>} />}>
|
||||
<PageLayout
|
||||
title="Users"
|
||||
actions={<CreateDialog
|
||||
trigger={<Button>Create User</Button>}
|
||||
existingEmails={allUsers.map(u => u.primaryEmail).filter(e => e !== null) as string[]}
|
||||
/>}
|
||||
>
|
||||
{allUsers.length > 0 ? null : (
|
||||
<Alert variant='success'>
|
||||
Congratulations on starting your project! Check the <StyledLink href="https://docs.stack-auth.com">documentation</StyledLink> to add your first users.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user