简体   繁体   English

AWS Amplify 中的 currentAuthenticatedUser() 和 currentUserPoolUser() 有什么区别?

[英]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。

according to amplify auth docs , both result in "A promise resolves to current authenticated CognitoUser if success"根据 amplify auth docs ,两者都会导致“如果成功,A promise 将解析为当前经过身份验证的 CognitoUser”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Auth.currentAuthenticatedUser() 和 Auth.currentSession() 有什么区别? - What is the difference between Auth.currentAuthenticatedUser() and Auth.currentSession()? AWS Amplify Sign In `currentAuthenticatedUser` 在登录后返回 `User is not authenticated` - AWS Amplify Sign In `currentAuthenticatedUser` returns `User is not authenticated` After Sign In AWS Amplify 和 amazon-cognito-identity-js 之间的区别? - The difference between AWS Amplify and amazon-cognito-identity-js? AWS 中的 ELB 和 ALB 有什么区别? - What is the difference between ELB and ALB in AWS? AWS Billing and Cost Management 和 AWS cost explorer 之间有什么区别? - What is the difference between AWS Billing and Cost Management and AWS cost explorer? AWS Elastic MapReduce 和 AWS Kinesis Data Analytics 有什么区别? - What is the difference between AWS Elastic MapReduce and AWS Kinesis Data Analytics? AWS::Serverless::Api 和 AWS::Serverless::HttpApi 有什么区别? - What is the difference between AWS::Serverless::Api and AWS::Serverless::HttpApi? AWS Glue ETL 作业和 AWS EMR 有什么区别? - What is the difference between AWS Glue ETL Job and AWS EMR? AWS Step Functions 中的超时和心跳有什么区别? - What is the difference between a Time Out and a Heart Beat in AWS Step Functions? 在 AWS cloudformation 中,自定义资源和资源提供者有什么区别? - In AWS cloudformation, what is the difference between a custom resource and a resource provider?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM