【问题标题】:AWS - Amplify - Is there a way to change or update user's email using amplify from the front end?AWS - Amplify - 有没有办法从前端使用放大来更改或更新用户的电子邮件?
【发布时间】:2018-10-30 21:02:49
【问题描述】:

我正在使用 cognito 电子邮件地址和 amplify Auth 登录...有没有办法从前端使用 amplify 更改或更新用户的电子邮件?

我还没有搞定。

谢谢。

【问题讨论】:

    标签: aws-amplify amplifyjs


    【解决方案1】:

    我刚刚找到它:updateUserAttributes

    https://aws-amplify.github.io/docs/js/authentication

    【讨论】:

      【解决方案2】:

      这很简单,

      https://serverless-stack.com/chapters/allow-users-to-change-their-email.html 和 https://docs.amplify.aws/lib/auth/manageusers/q/platform/js#managing-user-attributes

      您需要通过currentAuthenticatedUser 提供用户,然后致电updateUserAttributes 提供user 参考和新的电子邮件地址。

      const user = await Auth.currentAuthenticatedUser();
      await Auth.updateUserAttributes(user, { email: fields.email });
      

      有关如何在 Amplify with React 中管理用户信息的更多选项,请参阅此页面。

      https://serverless-stack.com/chapters/manage-user-accounts-in-aws-amplify.html

      【讨论】:

      • 旁注,如果您将 Cognito 设置为使用 username 身份验证而不是电子邮件,您将需要完全使用 amplify remove auth 将其添加回 email 身份验证才能使上述操作生效。此外,如果您使用的是用户池组,则需要先删除这些组,然后再删除 Cognito 资源。 (全部通过 Amplify)如果你搞砸了amplify pull --restore。
      【解决方案3】:

      请尝试此命令“放大更新身份验证”

      【讨论】:

      • 他想提供一个功能来允许用户更改他们的电子邮件地址。不更新 Cognito 基础架构的状态。
      猜你喜欢
      • 2020-03-02
      • 1970-01-01
      • 2021-07-06
      • 1970-01-01
      • 2021-05-01
      • 2014-08-28
      • 2020-07-29
      • 2020-12-09
      • 1970-01-01
      相关资源
      最近更新 更多