This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
Refactor cognitoData
to dedicated user
/session
objects
#773
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This splits the functionality/methods up a bit more.
This is a BREAKING CHANGE as it moves the methods around quite a bit. However, migration should be pretty mechanical, doable with search-and-replace:
Changed method locations:
cognito.restoreAndLoad()
remains the same;cognito.authenticate()
remains the same;cognito.authenticateUser()
-->cognito.unauthenticated.verifyUserAuthentication()
cognito.logout()
--> remains the samecognito.invalidateAccessTokens()
--> remains the samecognito.triggerResetPasswordMail()
-->cognito.unauthenticated.triggerResetPasswordMail()
cognito.updateResetPassword()
-->cognito.unauthenticated.updateResetPassword()
cognito.setNewPassword()
-->cognito.unauthenticated.setInitialPassword()
cognito.updatePassword()
-->cognito.user.updatePassword()
cognito.updateAttributes()
-->cognito.user.updateAttributes()
cognito.cognitoData.mfa
-->cognito.user.mfa
cognito.cognitoData.cognitoUser
-->cognito.user.cognitoUser
cognito.cognitoData.cognitoUserSession
-->cognito.session.cognitoUserSession
cognito.cognitoData.jwtToken
-->cognito.session.jwtToken
cognito.cognitoData.userAttributes
-->cognito.user.userAttributes
cognito.cognitoData.getAccessToken()
-->cognito.session.getAccessToken()
cognito.cognitoData.getIdToken()
-->cognito.session.getIdToken()
cognito.refreshAccessToken()
-->cognito.session.refresh()
cognitoData
is no moreAs you can see in the above section,
cognito.cognitoData
has been replaced withcognito.user
andcognito.session
.These two properties will be set when the user is authenticated, else they will be
undefined
. WhenisAuthenticated === true
you can assume they are set.In contrast,
unauthenticated
is always available.Change token auto-refresh
In 4.x, JWT tokens will not be automatically refreshed when they expire.
Instead, you can call
cognito.session.enableAutoRefresh()
andcognito.session.disableAutoRefresh()
to start/stop the auto-refresh background job.There are also some new/changed methods to work with token refreshing:
Other changes/news
This also drops the ember-concurrency dependency.