-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switching Unauthenticated Users to Authenticated Users In V6 #14197
Comments
Hi @thesnups Thanks for reporting this issue. IIRC, once an end user signs up for an account, it will be associated with an "authenticated user" Currently in v6, however, when an "unauthenticated user" signs up a new account, the "unauthenticated user" |
Hi @HuiSF , thank you for the response. It makes sense that for existing user accounts the guest identity ID would not replace the authenticated identity ID. As you suggested, I am referring specifically to the case where the guest identity ID becomes the authenticated identity ID when a user first signs up and in. This feature was added to V5, but it is not fully implemented in V6. There is code in V6 that appears to implement the feature, but it is not complete. Any idea when the team might be able to address this? |
Thanks for the confirmation @thesnups we will discuss internally and update the progress here. |
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
Not applicable
Backend
CDK
Environment information
Describe the bug
Context
In my React/Vite app I am using
amplify-js
to facilitate user authentication flows. I'm not using Amplify on the backend, but rather am configuringamplify-js
to use my existing AWS resources withAmplify.configure
. On the backend I have a Cognito user pool and identity pool. The identity pool has the user pool configured as an identity provider. These resources are deployed via CDK.Issue
Cognito supports upgrading/switching identity pool identities from "unauthenticated" to "authenticated" when a user logs in with an identity provider linked to the identity pool (source). When doing so, the identity ID is stable and a new linked login is added to the identity.
amplify-js@5
didn't initially support this feature, but a feature request was opened to track it, and eventually a PR was merged implementing the feature. When I began usingamplify-js@5
in my project I recall manually testing and verifying that the feature worked as expected.I am now in the process of upgrading to
amplify-js@6
, and it looks like the feature doesn't work anymore. When I visit my web app as an unauthenticated user, I am assigned anidentityId
. Then, after logging in, I am assigned a differentidentityId
. Instead of adding a linked login to the existing identity, a new identity is created, which replaces the previous one in the client. When I check identity pool identity browser in the AWS Console, I can see both identities: the original "guest" identity with no linked logins, and a new "authenticated" identity with a linked login.I spent some time reading the
amplify-js@6
code, and it looks like the intention was to port this feature over from v5. Specifically, these lines of code appear to implement the feature. However, in practice the feature does not work. I think the issue is that this line of code, as it is written, can never produce the same identity ID as the guest identity. It will always return a new identity ID from Cognito:Looking back at the v5 code, it appears the credential provider needs to make a
GetCredentialsForIdentity
call with the guest identity ID and the linked login in order to merge them and "upgrade" the identity.Expected behavior
When visiting the app for the first time, a user is assigned a new "guest" identity ID with no linked logins. Then, if the user signs up and/or signs in with an identity provider, they keep the same identity and identity ID, but the new login info is added as a linked login to the identity.
Reproduction steps
fetchAuthSession
function on the window, enabling you to call it from the dev tools console:amplify-js
will generate a new identity for the unauthenticated session. Get the identity ID usingfetchAuthSession
in the dev tools console:fetchAuthSession
to get your identity ID:Both identities can be seen in the AWS Console in Cognito's identity pool identity browser.
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: