更改Cognito用户池/ AWS放大;导致注册问题 [英] Changing Cognito-User-Pool/AWS-Amplify; leading to SignUp issue

查看:147
本文介绍了更改Cognito用户池/ AWS放大;导致注册问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AWS-Amplify(和Cognito)在iOS应用中处理一些SignUp / SignIn流程。

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)")
                                }
        })
}

在我做了必要的操作(使用amplify-cli)之后,删除了旧的用户池并创建了一个新的用户池。我重新编译了我的iOS应用程序并启动了它。

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:

消息内容不足为奇,因为现在我需要指定字段。
但是问题是我在UI中看不到用于输入这些新字段的空间。

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.

我忘了做点什么,用户界面是否可以充分更新?
还是我想通过修改上面的函数来做一些事情(手动更新UI)?如果是,那么进行更改的方式是什么?

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.

推荐答案

我仅使用带有JavaScript的AWS Amplify,但是在JS中,您需要手动更新UI。

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

这是JS代码,我该如何手动调用它,也许会有所帮助。

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);
    }
  }
};

这篇关于更改Cognito用户池/ AWS放大;导致注册问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆