[英]what is difference between currentAuthenticatedUser() and currentUserPoolUser() in AWS Amplify?
I have read the AWS Amplify API
and I have found some weird thing.我已阅读AWS Amplify API
,发现了一些奇怪的东西。
I've found 2 similar functions我发现了2个类似的功能
currentAuthenticatedUser()
and currentUserPoolUser()
. currentAuthenticatedUser()
和currentUserPoolUser()
。
They have the same description, parameters, and returns.它们具有相同的描述、参数和返回值。
I want to know why they separated.我想知道他们为什么分开。
[reference] [参考]
https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#currentauthenticateduser https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#currentauthenticateduser
https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#currentuserpooluser https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#currentuserpooluser
I believe user pool users are those that are from Cognito, whereas an authenticated user is one that come from an identity pool (from a federated identity).我相信用户池用户是来自 Cognito 的用户,而经过身份验证的用户是来自身份池(来自联合身份)的用户。
See: https://aws.amazon.com/premiumsupport/knowledge-center/cognito-user-pools-identity-pools/请参阅: https://aws.amazon.com/premiumsupport/knowledge-center/cognito-user-pools-identity-pools/
From the code , it looks like currentAuthenticatedUser checks for federation info.从代码看来,currentAuthenticatedUser 检查联合信息。 However, if it doesn't find federation info, it just calls currentUserPoolUser.但是,如果它没有找到联合信息,它只会调用 currentUserPoolUser。 So I'd say call currentUserPoolUser if you know you're never going to be using federated logins, but you should probably call currentAuthenticatedUser if there's a chance you might.因此,如果您知道您永远不会使用联合登录,我会说调用 currentUserPoolUser,但如果有机会,您应该调用 currentAuthenticatedUser。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.