英文:
JavaScript: AWS Amplify : How to get the User Id(Sub ID) after user signs Up. After SignsUP not Sign In
问题
我正在使用由Aws Amplify提供的Auth模块。我在思考用户注册后如何检索userID。
我可以在用户登录后获取ID,但我希望在注册过程中获取userID,以便在登录之前更新我的一些模型。
我在注册响应中没有看到userID。我想知道是否有任何解决方法?
英文:
I am using the Auth Module Provided by Aws Amplify.I am contemplating how can I retrieve the
userID once the user signs up.
I can get the ID once the user Signs In, however, I want to get the userID during SignUp Process so I can update some of my model before logging in.
I didn't see userId in my signUp response. I am wondering if there is any workaround for that ?
答案1
得分: 0
Id包含在响应的userSub
部分中,因此是result.userSub
。
Auth.signUp({
username: username,
password: password,
attributes: attributes
}).then((result) => {
console.log(result.userSub)
})
响应评论:
从signUp的结果是:
{
user: CognitoUser;
userConfirmed: boolean;
userSub: string;
}
来源:https://docs.amplify.aws/lib/auth/emailpassword/q/platform/js/#sign-up
英文:
The Id is contained in the userSub
part of the response, so result.userSub
.
Auth.signUp({
username: username,
password: password,
attributes: attributes
}).then((result) => {
console.log(result.userSub)
})
In response to comment:
The result from signUp is:
{
user: CognitoUser;
userConfirmed: boolean;
userSub: string;
}
Source: https://docs.amplify.aws/lib/auth/emailpassword/q/platform/js/#sign-up
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论