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

Remove cached data when logging out #1815

Merged
merged 1 commit into from
Apr 21, 2022
Merged

Remove cached data when logging out #1815

merged 1 commit into from
Apr 21, 2022

Conversation

Vinnl
Copy link
Collaborator

@Vinnl Vinnl commented Apr 20, 2022

This is a follow-up to #1777 (review) by @groovecoder.

Although we now properly detect that a user is logged out after
mocking logout, the user's data would still be cached, such as the
fact that they're a Premium user, causing the header to still be
in the Premium theme.

With this change, user data is also cleared.

Note that this only affected when running using the dev server, as
authentication in production involves full page reloads and hence
the clearing of all in-memory data.

How to test: Log in as a Premium user when running using the dev server. Now logout. Observe that the "Sign up" and "Sign in" buttons are visible again, and that the header is now dark.

  • l10n changes have been submitted to the l10n repository, if any.
  • I've added a unit test to test for potential regressions of this bug. No, mocking both the router and the user API for what is otherwise a static page felt like overkill, but let me know if you disagree.
  • I've added or updated relevant docs in the docs/ directory.
  • All UI revisions follow the coding standards, and use Protocol tokens where applicable (see /static/scss/libs/protocol/css/includes/tokens/dist/index.scss).
  • Commits in this PR are minimal and have descriptive commit messages.

Although we now properly detect that a user is logged out after
mocking logout, the user's data would still be cached, such as the
fact that they're a Premium user, causing the header to still be
in the Premium theme.

With this change, user data is also cleared.

Note that this only affected when running using the dev server, as
authentication in production involves full page reloads and hence
the clearing of all in-memory data.
@Vinnl Vinnl requested a review from groovecoder April 20, 2022 11:14
@Vinnl Vinnl self-assigned this Apr 20, 2022
// Revalidate account data to reflect logged out status.
// Note that the `clear` method exists, even though it's not exposed on the
// type yet:
// https://github.com/vercel/swr/issues/161#issuecomment-1079198998
Copy link
Member

Choose a reason for hiding this comment

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

praise: thanks for sending a PR upstream! I subscribed to it to hopefully help remember when we can remove this work-around.

@groovecoder groovecoder merged commit 75f23a8 into main Apr 21, 2022
@groovecoder groovecoder deleted the dev-logout branch April 21, 2022 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants