Skip to content

Prevent isAdminMode from becoming undefined and ensure false is stored correctly#1738

Open
joshdimanteto wants to merge 4 commits intodevelopfrom
fix/redux-listener-error
Open

Prevent isAdminMode from becoming undefined and ensure false is stored correctly#1738
joshdimanteto wants to merge 4 commits intodevelopfrom
fix/redux-listener-error

Conversation

@joshdimanteto
Copy link
Contributor

@joshdimanteto joshdimanteto commented Mar 3, 2026

Description

This PR fixes an issue where isAdminMode could become undefined after calling setAuthorisation, causing the authorisation listener middleware to attempt storing undefined into local storage.

Key Fixes:

  • setAuthorisation now guarantees isAdminMode is always a boolean.
  • Prevents accidental writes of undefined to the storage layer.

Restores intended behaviour:

  • isAdminMode persists as true or false
  • Non‑admin users always reset to false
  • Admin users retain their current mode unless explicitly changed

Testing instructions

Add a set up instructions describing how the reviewer should test the code

  • Review code
  • Check Actions build
  • Review changes to test coverage
  • Admin login retains correct isAdminMode state
  • Non-admin login clears admin mode
  • Middleware no longer writes undefined to storage
  • Hydration logic works correctly for true/false values

@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.83%. Comparing base (686a86b) to head (8eaf626).

Files with missing lines Patch % Lines
src/App.tsx 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1738      +/-   ##
===========================================
- Coverage    92.98%   92.83%   -0.15%     
===========================================
  Files           13       13              
  Lines          627      628       +1     
  Branches       195      193       -2     
===========================================
  Hits           583      583              
- Misses          44       45       +1     

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

Copy link
Contributor

@joelvdavies joelvdavies left a comment

Choose a reason for hiding this comment

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

In the testing instructions you say Admin login retains correct isAdminMode state - If I log out as admin then log back in then it gets reset, so that isnt met. I believe because it deletes it on logout. I checked adding the local storage item and then logging in as a non admin and it did clear it so that way round worked as I would hope.

@joshdimanteto
Copy link
Contributor Author

In the testing instructions you say Admin login retains correct isAdminMode state - If I log out as admin then log back in then it gets reset, so that isnt met. I believe because it deletes it on logout. I checked adding the local storage item and then logging in as a non admin and it did clear it so that way round worked as I would hope.

This should be fixed now, Also this pr need to get merged in before #1717 as it fixes a bug i found

@joshdimanteto joshdimanteto marked this pull request as ready for review March 10, 2026 10:52
@joshdimanteto joshdimanteto force-pushed the fix/redux-listener-error branch from 80cfcc3 to c8f7122 Compare March 10, 2026 12:04
@joshdimanteto joshdimanteto force-pushed the fix/redux-listener-error branch from c8f7122 to 5d853d0 Compare March 10, 2026 12:29
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