mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 15:06:59 +00:00
Fix sign up error message not showing up
This commit is contained in:
parent
87134e2990
commit
5cb03db3ea
@ -34,8 +34,8 @@ const signup: SignupEndpoint['handlers']['signup'] = async ({
|
||||
})
|
||||
} catch (error) {
|
||||
if (error instanceof BigcommerceApiError && error.status === 422) {
|
||||
const hasEmailError = '0.email' in error.data?.errors
|
||||
|
||||
const hasEmailError = '.customer_create' in error.data?.errors
|
||||
const hasPasswordError = '0.password' in error.data?.errors
|
||||
// If there's an error with the email, it most likely means it's duplicated
|
||||
if (hasEmailError) {
|
||||
return res.status(400).json({
|
||||
@ -48,6 +48,18 @@ const signup: SignupEndpoint['handlers']['signup'] = async ({
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
if (hasPasswordError) {
|
||||
return res.status(400).json({
|
||||
data: null,
|
||||
errors: [
|
||||
{
|
||||
message: 'Passwords must be longer than 7 chars and include numbers',
|
||||
code: 'duplicated_email',
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
throw error
|
||||
|
Loading…
x
Reference in New Issue
Block a user