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

Reset store state on logout #5120

Merged
merged 4 commits into from
Feb 18, 2025
Merged

Reset store state on logout #5120

merged 4 commits into from
Feb 18, 2025

Conversation

cstns
Copy link
Contributor

@cstns cstns commented Feb 14, 2025

Description

adds a global way of resetting store state on user logou

Related Issue(s)

closes #5115

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production

Labels

  • Includes a DB migration? -> add the area:migration label

@cstns cstns self-assigned this Feb 14, 2025
Copy link

codecov bot commented Feb 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.26%. Comparing base (71b2bab) to head (213b3a5).
Report is 48 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5120      +/-   ##
==========================================
- Coverage   78.26%   78.26%   -0.01%     
==========================================
  Files         339      339              
  Lines       15967    15985      +18     
  Branches     3693     3697       +4     
==========================================
+ Hits        12497    12511      +14     
- Misses       3470     3474       +4     
Flag Coverage Δ
backend 78.26% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cstns cstns requested a review from knolleary February 14, 2025 09:59
@cstns
Copy link
Contributor Author

cstns commented Feb 14, 2025

I'd propose to keep the platform settings in local storage, reason being that clearing the account state on logout could pose problems to the login page (rendering platform setting dependent elements like the sign-up button).

There's nothing in there that could be considered sensitive and the data is not subject to change very often either

@knolleary
Copy link
Member

Sorry - I'm out of time to get this reviewed. Will need to pass over to someone else.

@cstns cstns requested a review from joepavitt February 18, 2025 10:35
@joepavitt
Copy link
Contributor

can you explain why we have two resetState calls, one as a mutation and another as an action? What am i missing?

@cstns
Copy link
Contributor Author

cstns commented Feb 18, 2025

Yes, in Vuex, all state changes must pass through mutations.

This ensures that state updates are synchronous and trackable (actions can contain async logic but must commit mutations to modify the state). Even though in this particular case the action doesn't contain async code, directly modifying the state outside mutations violates Vuex principles and may lead to unexpected behavior

initialState = initialState()

if (meta.persistence) {
// remove any initial state keys from the initial state that should be ignored while clearing state
Copy link
Contributor

Choose a reason for hiding this comment

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

've read this line many times, and I can't process/understand it, can you clear it up please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is Skip clearing state keys that should be persisted across state resets a bit better?

@joepavitt joepavitt merged commit 6bc8589 into main Feb 18, 2025
21 checks passed
@joepavitt joepavitt deleted the reset-store-state-on-logout branch February 18, 2025 14:10
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.

Add a robust way to clear storage across vuex store on user logout
3 participants