简体   繁体   English

AWS Amplify Authenticator UI 确认登录错误

[英]AWS Amplify Authenticator UI confirm signin error

I am using AWS Amplify Authenticator UI components for my signin, SMS verification etc.我使用 AWS Amplify Authenticator UI 组件进行登录、短信验证等。

I am able to signup, signin without MFA perfectly fine.我可以在没有 MFA 的情况下进行注册和登录。 When I enable SMS MFA the 'AmplifyConfirmSignIn' component asks for the SMS code, but after entering the code it throws the below error.当我启用 SMS MFA 时,“AmplifyConfirmSignIn”组件要求输入 SMS 代码,但在输入代码后,它会引发以下错误。

Uncaught (in promise) TypeError: Cannot read property 'challengeName' of undefined

Below is my code,下面是我的代码,

{ authState !== 'signedin' ?
    <AmplifyAuthenticator usernameAlias="email" amplifyConfig={awsconfig} >
    <div slot="sign-in" className="amplifyCont">
      <AmplifySignIn slot="sign-in" usernameAlias="email" />
      </div>
      <div slot="sign-up" className="amplifyCont">
      <AmplifySignUp
        slot="sign-up"
        usernameAlias="email"
        formFields={[
          {
            type: "name",
            label: "First Name",
            placeholder: "John",
            required: true,
          },
          {
            type: "family_name",
            key: "family_name",
            label: "Last Name",
            placeholder: "Doe",
            required: true,
          },
          {
            type: "email",
            label: "Email Address",
            placeholder: "email@sample.com",
            required: true,
          },
          {
            type: "password",
            label: "Password",
            placeholder: "Password with both cases, symbol and number",
            required: true,
          },
          {
            type: "phone_number",
            label: "Phone Number",
            placeholder: "Primary Contact",
            required: false,
          },
        ]}
      />
      </div>
      <div slot="forgot-password" className="amplifyCont">
      <AmplifyForgotPassword slot="forgot-password" />
      </div>
      <div slot="require-new-password" className="amplifyCont">
      <AmplifyRequireNewPassword slot="require-new-password" />
      </div>
      <div slot="confirm-sign-in" className="amplifyCont" >
      <AmplifyConfirmSignIn slot="confirm-sign-in" />
      </div>
      
      </AmplifyAuthenticator>
      :
      <div className="App">

I searched through the Authenticator docs and google, but I could not find a solution.我搜索了 Authenticator 文档和谷歌,但找不到解决方案。 Please help me out.请帮帮我。

I figured out a solution, we need to provide the 'user' attribute to the confirm-signin component.我想出了一个解决方案,我们需要为确认登录组件提供“用户”属性。

<AmplifyConfirmSignIn slot="confirm-sign-in" user={userVal} />

I got the signed in user details via the onAuthUIStateChange handler.我通过 onAuthUIStateChange 处理程序获得了登录的用户详细信息。

 React.useEffect(() => {
return onAuthUIStateChange((nextAuthState, authData) => {
   setUserVal(authData);
});}, []);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM