AWS Amplify 中的 currentAuthenticatedUser() 和 currentUserPoolUser() 有什么区别?
what is difference between currentAuthenticatedUser() and currentUserPoolUser() in AWS Amplify?
我已经阅读了 AWS Amplify API
并且发现了一些奇怪的东西。
我找到了 2 个相似的函数
currentAuthenticatedUser()
和 currentUserPoolUser()
.
它们具有相同的描述、参数和 returns。
我想知道他们为什么分开
[参考]
https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#currentauthenticateduser
https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#currentuserpooluser
我认为用户池用户是来自 Cognito 的用户,而经过身份验证的用户是来自身份池(来自联合身份)的用户。
参见:https://aws.amazon.com/premiumsupport/knowledge-center/cognito-user-pools-identity-pools/
根据 amplify auth docs,两者都会导致“如果成功,承诺将解析为当前经过身份验证的 CognitoUser”
从 code 来看,currentAuthenticatedUser 似乎在检查联合信息。但是,如果它没有找到联合信息,它只会调用 currentUserPoolUser。所以我会说,如果您知道自己永远不会使用联合登录,请调用 currentUserPoolUser,但如果有机会,您应该调用 currentAuthenticatedUser。
我已经阅读了 AWS Amplify API
并且发现了一些奇怪的东西。
我找到了 2 个相似的函数
currentAuthenticatedUser()
和 currentUserPoolUser()
.
它们具有相同的描述、参数和 returns。
我想知道他们为什么分开
[参考]
https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#currentauthenticateduser
https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#currentuserpooluser
我认为用户池用户是来自 Cognito 的用户,而经过身份验证的用户是来自身份池(来自联合身份)的用户。
参见:https://aws.amazon.com/premiumsupport/knowledge-center/cognito-user-pools-identity-pools/
根据 amplify auth docs,两者都会导致“如果成功,承诺将解析为当前经过身份验证的 CognitoUser”
从 code 来看,currentAuthenticatedUser 似乎在检查联合信息。但是,如果它没有找到联合信息,它只会调用 currentUserPoolUser。所以我会说,如果您知道自己永远不会使用联合登录,请调用 currentUserPoolUser,但如果有机会,您应该调用 currentAuthenticatedUser。