Skip to content
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

Fix refresh token flow #1235

Merged
merged 2 commits into from
Jul 6, 2021
Merged

Fix refresh token flow #1235

merged 2 commits into from
Jul 6, 2021

Conversation

FSM1
Copy link
Contributor

@FSM1 FSM1 commented Jul 5, 2021

Closes #1224

Replace call to the session storage helper with direct browser Api calls to sessionStorage.getItem() inside the refresh token handler.

@render
Copy link

render bot commented Jul 5, 2021

@render
Copy link

render bot commented Jul 5, 2021

@FSM1 FSM1 requested a review from Tbaut July 5, 2021 21:18
@github-actions github-actions bot added the Type: Bug Fix Added to PRs if they are addressing a bug label Jul 5, 2021
@FSM1 FSM1 requested review from RyRy79261 and tanmoyAtb July 5, 2021 21:18
@FSM1 FSM1 self-assigned this Jul 5, 2021
@FSM1 FSM1 added Release: Patch only for PROD release PR Status: Review Needed 👀 Added to PRs when they need more review labels Jul 5, 2021
Copy link
Collaborator

@Tbaut Tbaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I had a look at the code, and I'm not sure I understand the withLocalStorage altogether. If you recall what this is @FSM1 and let me know, I'd be happy to add some comments about it.

@FSM1
Copy link
Contributor Author

FSM1 commented Jul 6, 2021

Looks good, I had a look at the code, and I'm not sure I understand the withLocalStorage altogether. If you recall what this is @FSM1 and let me know, I'd be happy to add some comments about it.

When the FilesApiContext was originally built, it was meant to be more generic component, and a flag could be passed in that would determine where the refresh token was stored (local or session).

The real issue this ticket solves is that the initialize useEffect (which we really only want to run once) did not have the sessionStorageGet and localStorageGet functions as part of the dependency array, and as such these were always resolving to undefined (in the context of the refresh token handling flow), and no token refresh was happening. Using the browser API directly solves this issue.

Since Files is only using session storage for the refresh token, I just removed the localStorage branch of the ternary.

@FSM1 FSM1 merged commit 214510b into dev Jul 6, 2021
@FSM1 FSM1 deleted the fix/refresh-token-on-expired-access-token branch July 6, 2021 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release: Patch only for PROD release PR Status: Review Needed 👀 Added to PRs when they need more review Type: Bug Fix Added to PRs if they are addressing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Access Token Refresh flow not working
3 participants