multierror
This commit is contained in:
parent
2952e15591
commit
f288cc3388
|
@ -97,17 +97,24 @@ export const LoginForm = () => {
|
|||
const { errors } = await signIn({ email: email(), password: password() })
|
||||
if (errors?.length > 0) {
|
||||
console.warn('[signIn] errors: ', errors)
|
||||
|
||||
if (errors.some((error) => error.message === 'user has not signed up email & password')) {
|
||||
const password = t('Something went wrong, check email and password')
|
||||
setValidationErrors((prev) => ({ ...prev, password }))
|
||||
} else if (errors.some((error) => error.message === 'user not found')) {
|
||||
const email = t('User was not found')
|
||||
setValidationErrors((prev) => ({ ...prev, email }))
|
||||
} else if (errors.some((error) => error.message === 'email not verified')) {
|
||||
const email = t('This email is not verified')
|
||||
setValidationErrors((prev) => ({ ...prev, email }))
|
||||
} else {
|
||||
errors.forEach((error) => {
|
||||
switch (error.message) {
|
||||
case 'user has not signed up email & password': {
|
||||
setValidationErrors((prev) => ({
|
||||
...prev,
|
||||
password: t('Something went wrong, check email and password'),
|
||||
}))
|
||||
break
|
||||
}
|
||||
case 'user not found': {
|
||||
setValidationErrors((prev) => ({ ...prev, email: t('User was not found') }))
|
||||
break
|
||||
}
|
||||
case 'email not verified': {
|
||||
setValidationErrors((prev) => ({ ...prev, email: t('This email is not verified') }))
|
||||
break
|
||||
}
|
||||
default:
|
||||
setSubmitError(
|
||||
<div class={styles.info}>
|
||||
{t('Error', errors[0].message)}
|
||||
|
@ -118,7 +125,7 @@ export const LoginForm = () => {
|
|||
</div>,
|
||||
)
|
||||
}
|
||||
|
||||
})
|
||||
return
|
||||
}
|
||||
hideModal()
|
||||
|
|
Loading…
Reference in New Issue
Block a user