簡體   English   中英

AWS Amplify 中的 currentAuthenticatedUser() 和 currentUserPoolUser() 有什么區別?

[英]what is difference between currentAuthenticatedUser() and currentUserPoolUser() in AWS Amplify?

我已閱讀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

我相信用戶池用戶是來自 Cognito 的用戶,而經過身份驗證的用戶是來自身份池(來自聯合身份)的用戶。

請參閱: https://aws.amazon.com/premiumsupport/knowledge-center/cognito-user-pools-identity-pools/

代碼看來,currentAuthenticatedUser 檢查聯合信息。 但是,如果它沒有找到聯合信息,它只會調用 currentUserPoolUser。 因此,如果您知道您永遠不會使用聯合登錄,我會說調用 currentUserPoolUser,但如果有機會,您應該調用 currentAuthenticatedUser。

根據 amplify auth docs ,兩者都會導致“如果成功,A promise 將解析為當前經過身份驗證的 CognitoUser”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM