【问题标题】:what is difference between currentAuthenticatedUser() and currentUserPoolUser() in AWS Amplify?AWS Amplify 中的 currentAuthenticatedUser() 和 currentUserPoolUser() 有什么区别?
【发布时间】:2020-09-03 22:19:12
【问题描述】:

我阅读了AWS Amplify API,发现了一些奇怪的东西。

我找到了 2 个类似的功能

currentAuthenticatedUser() 和 currentUserPoolUser()。

它们具有相同的描述、参数和返回值。

我想知道他们为什么分开。

[参考]

https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#currentauthenticateduser

https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#currentuserpooluser

【问题讨论】:

    标签: amazon-web-services aws-amplify


    【解决方案1】:

    我相信用户池用户是来自 Cognito 的用户,而经过身份验证的用户是来自身份池(来自联合身份)的用户。

    见:https://aws.amazon.com/premiumsupport/knowledge-center/cognito-user-pools-identity-pools/

    【讨论】:

    • 但是没有函数名它们是 100% 相同的。
    • 它们遵循相同的架构 (SAML 2.0),但这将联合用户与 cognito 用户池用户分开
    • 你能解释一下我应该为log in使用哪个函数吗?
    • 这取决于您的用户群来自哪里
    【解决方案2】:

    根据放大auth docs,两者都会导致“如果成功,承诺将解析为当前经过身份验证的 CognitoUser”

    【讨论】:

      【解决方案3】:

      从code 看来,currentAuthenticatedUser 检查联合信息。但是,如果它没有找到联合信息,它只会调用 currentUserPoolUser。因此,如果您知道自己永远不会使用联合登录,我会说调用 currentUserPoolUser,但如果有机会,您可能应该调用 currentAuthenticatedUser。

      【讨论】:

        猜你喜欢
        • 2020-09-20
        • 2022-01-16
        • 1970-01-01
        • 2016-02-13
        • 2018-07-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-05-19
        相关资源
        最近更新 更多