Changing Cognito-User-Pool/AWS-Amplify; leading to SignUp issue

旧城冷巷雨未停 提交于 2019-12-25 03:16:28

问题


I am, handling some SignUp/SignIn process within an iOS app, using AWS-Amplify (and Cognito).

It was working fine, but then I decided to require a few more information when signing up. Namely: name, given_name, family_name.

Here is the function called to authenticate:

func showSignIn() {
    AWSAuthUIViewController
        .presentViewController(with: self.navigationController!,
                               configuration: nil,
                               completionHandler: {
                                (provider: AWSSignInProvider, error: Error?) in
                                if error != nil {
                                    print("Error occurred: \(String(describing: error))")
                                } else {
                                    print("Identity provider: \(provider.identityProviderName)")
                                }
        })
}

After I did the necessary manipulations (using amplify-cli) to remove the old user pool and make a new one. I recompiled my iOS app and launched it.

This was OK, but now when I want to sign up a user I get this message:

The message content is not surprising, since now I require the indicated fields. But the problem is that I don't see any space in the UI where to input those new fields.

Did I forget to do something so that the UI could be updated adequately? Or am I suppose to do something (to update the UI by hand) by modifying the function above? If YES, what is the way to make the change?

These are my first steps with amplify, I may well be making some basic mistakes.


回答1:


I'm only using AWS Amplify with JavaScript, but in JS you do need to update the UI manually.

Here is the JS code and how I have to call it manually, maybe this helps.

handleSignUpPressed = async ({
  emailAddress = '',
  firstName = '',
  lastName = '',
  password = '',
  phoneNumber = '',
  wantsToImproveApp = true,
} = {}) => {
  if (emailAddress && firstName && lastName && password && phoneNumber) {
    try {
      const res = await Auth.signUp({
        username: emailAddress,
        password,
        attributes: {
          email: emailAddress,
          name: firstName,
          family_name: lastName,
          phone_number: phoneNumber,
        },
      });
      console.log('success', res);
      this.props.navigation.push('VerificationScreen', {
        username: res.username,
      });
    } catch (err) {
      console.log(err);
    }
  }
};


来源:https://stackoverflow.com/questions/56616931/changing-cognito-user-pool-aws-amplify-leading-to-signup-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!