Add more verification to sign up

This commit is contained in:
Kurt Hutten
2021-09-30 20:28:13 +10:00
parent 879f24b08b
commit 3aa3254e48
3 changed files with 52 additions and 1 deletions

View File

@@ -35,6 +35,13 @@ const LoginModal = ({ open, onClose, shouldStartWithSignup = false }) => {
if (checkBox) {
subscribe({ email, addMessage: (msg) => toast.error(msg), name })
}
const { isUserNameAvailable } = await fetch(
`/.netlify/functions/check-user-name?username=${userName}`
).then((res) => res.json())
if (!isUserNameAvailable) {
setError('UserName is already taken, please try something else')
return
}
await signUp({
email,
password,
@@ -167,6 +174,10 @@ const SignUpForm = ({ onSubmitSignUp, checkBox, setCheckBox, onClose }) => (
value: /^[a-zA-Z0-9-_]+$/,
message: 'Only alphanumeric and dash characters allowed',
},
minLength: {
value: 5,
message: 'Not enough Characters',
},
}}
/>
<Field