【发布时间】:2018-10-30 21:02:49
【问题描述】:
我正在使用 cognito 电子邮件地址和 amplify Auth 登录...有没有办法从前端使用 amplify 更改或更新用户的电子邮件?
我还没有搞定。
谢谢。
【问题讨论】:
标签: aws-amplify amplifyjs
我正在使用 cognito 电子邮件地址和 amplify Auth 登录...有没有办法从前端使用 amplify 更改或更新用户的电子邮件?
我还没有搞定。
谢谢。
【问题讨论】:
标签: aws-amplify amplifyjs
我刚刚找到它:updateUserAttributes
【讨论】:
这很简单,
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
【讨论】:
username 身份验证而不是电子邮件,您将需要完全使用 amplify remove auth 将其添加回 email 身份验证才能使上述操作生效。此外,如果您使用的是用户池组,则需要先删除这些组,然后再删除 Cognito 资源。 (全部通过 Amplify)如果你搞砸了amplify pull --restore。
请尝试此命令“放大更新身份验证”
【讨论】: