暴露 Auth.forgotPassword 和其他 Auth 方法的错误消息

问题描述 投票:0回答:1

有没有办法查看从

@aws-amplify/auth
Auth 方法返回的所有可用错误消息?

当使用正确的用户名拨打

Auth.forgotPassword
时,我会收到验证码以重置我的密码。但是,当我输入无效的用户名时,没有错误。我在这里做错了什么吗?当尝试太多次时,我收到了 LimiteRateExceeded 错误,但没有其他错误。

值得注意的是,我没有使用默认的 amplify React ui,而是使用我自己的调用 onSubmit 的表单。

这是我的 onSubmit 函数,它调用

Auth.forgotPassword

const onSubmitStep1 = async (formData: any) => {
        console.log('formData1', formData)
        setSubmitting(true)
        await Auth.forgotPassword(formData.email)
            .then(() => {
                setSubmitting(false)
                stepForward()
            })
            .catch((err) => {
                console.log(err.message)
                setAmplifyErrors({
                    ...amplifyErrors,
                    form1: err.message,
                })
            })
    }
reactjs amazon-cognito aws-amplify
1个回答
0
投票

根据您的需求,我认为此页面列出了您在调用 Auth.forgotPassword() 时可能遇到的所有错误。 https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ForgotPassword.html

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.