Repository navigation
fix(authentication-client): prioritize window.location token over stored token in getAccessToken - #3733
Open
EnesKartal wants to merge 1 commit into
Open
fix(authentication-client): prioritize window.location token over stored token in getAccessToken#3733EnesKartal wants to merge 1 commit into
EnesKartal wants to merge 1 commit into
Conversation
…red token in getAccessToken
Member
|
Thank you. This has been discussed before in #3633 (and other issues which I still can't seem to find). |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #3631
Summary
Previously,
AuthenticationClient.getAccessToken()checkedthis.storage.getItem(this.options.storageKey)first and only calledthis.getFromLocation(window.location)if no token was found in storage. When a user already had an access token in storage and navigated to a URL containing a new token (such as a magic link or OAuth callback), the new token inwindow.locationwas ignored and the old stored token continued to be used.Changes
packages/authentication-client/src/core.ts:getAccessToken()to checkthis.getFromLocation(window.location)first whenwindow.locationis available.window.location, removes any existing stored token viathis.removeAccessToken()and returns the new token.this.storage.getItem(this.options.storageKey)when no token is present inwindow.location.packages/authentication-client/test/index.test.ts:getAccessToken()prefers a token inwindow.locationover an existing stored token, clears the hash, and removes the stale token from storage.Verification
npx lerna run compile --scope=@feathersjs/authentication-client --include-dependencies(succeeded for 16 projects)npm test --workspace=@feathersjs/authentication-client(27 passing)npx prettier --check packages/authentication-client/src/core.ts packages/authentication-client/test/index.test.ts(passed)npx eslint packages/authentication-client/src/core.ts packages/authentication-client/test/index.test.ts(passed)