-
-
Notifications
You must be signed in to change notification settings - Fork 51
fix: feature disabled screen appearing after logout/login #462
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
base: feat/develop
Are you sure you want to change the base?
fix: feature disabled screen appearing after logout/login #462
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughLogin page now invalidates the FeatureFlags RTK Query cache upon successful standard or 2FA login, then navigates to /dashboard. Imports FeatureFlagsApi and dispatches FeatureFlagsApi.util.invalidateTags(['FeatureFlags']) in both success paths. No exported/public API changes. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant L as Login Page
participant A as Auth API
participant FF as FeatureFlagsApi (RTK Query)
participant R as Router
U->>L: Submit credentials / 2FA
L->>A: POST /login or /2fa
A-->>L: { access_token } (success)
rect rgba(200,240,255,0.3)
note right of L: New step: ensure fresh flags
L->>FF: dispatch(util.invalidateTags(['FeatureFlags']))
end
L->>R: navigate('/dashboard')
Note over L,R: Error paths unchanged
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
view/app/login/page.tsx
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: GitGuardian Security Checks
🔇 Additional comments (2)
view/app/login/page.tsx (2)
11-11
: LGTM!The import addition is necessary for invalidating the feature flags cache and follows standard RTK Query patterns.
68-68
: LGTM!Cache invalidation is consistently applied in the 2FA login flow, ensuring users who authenticate via two-factor authentication also receive fresh feature flags data.
expiresIn: response.expires_in | ||
}) | ||
); | ||
dispatch(FeatureFlagsApi.util.invalidateTags(['FeatureFlags'])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
LGTM! Request verification for logout flow and other entry points.
The cache invalidation correctly addresses the stale feature flags issue. Placement after setCredentials
and before navigation ensures the cache is marked as stale before the dashboard loads, triggering an automatic refetch.
Please verify the following to ensure comprehensive coverage:
-
Logout flow: Does the logout flow also invalidate the feature flags cache? While login invalidation ensures fresh data, clearing on logout prevents any edge cases where cached data might persist.
-
Tag name: Confirm that
'FeatureFlags'
matches the tag defined inFeatureFlagsApi
to ensure the invalidation targets the correct cache. -
Other authentication flows: Check if there are other login mechanisms (OAuth, SSO, magic links, etc.) that also need cache invalidation.
Run the following script to check for other authentication entry points:
🏁 Script executed:
#!/bin/bash
# Description: Find other authentication/login flows that might need cache invalidation
# Search for logout implementations
echo "=== Checking logout flows ==="
rg -n -C5 'logout|signOut|logOut' --type=tsx --type=ts -g '!node_modules' -g '!*.test.*' -g '!*.spec.*'
# Search for other authentication methods
echo -e "\n=== Checking for other auth flows ==="
rg -n -C3 '\b(oauth|sso|magic.?link|social.?auth)\b' --type=tsx --type=ts -g '!node_modules' -g '!*.test.*' -g '!*.spec.*' -i
# Verify FeatureFlags tag definition
echo -e "\n=== Verifying FeatureFlags tag ==="
rg -n -C5 "providesTags.*FeatureFlags|tagTypes.*FeatureFlags" --type=tsx --type=ts -g '!node_modules'
Length of output: 188
🏁 Script executed:
#!/bin/bash
echo "=== Checking logout flows ==="
rg -n -C5 'logout|signOut|logOut' --glob '*.ts' --glob '*.tsx' --glob '!*.test.*' --glob '!*.spec.*'
echo -e "\n=== Checking for other auth flows ==="
rg -n -C3 '\b(oauth|sso|magic.?link|social.?auth)\b' --glob '*.ts' --glob '*.tsx' --glob '!*.test.*' --glob '!*.spec.*' -i
echo -e "\n=== Verifying FeatureFlags tag ==="
rg -n -C5 "providesTags.*FeatureFlags|tagTypes.*FeatureFlags" --glob '*.ts' --glob '*.tsx'
Length of output: 10891
Invalidate FeatureFlags cache on logout The handleLogout
in view/components/layout/nav-user.tsx
resets other API states but omits FeatureFlagsApi
, causing stale feature flags after logout. Add dispatch(FeatureFlagsApi.util.invalidateTags(['FeatureFlags']))
or include FeatureFlagsApi
in your resetApiStates
list.
🤖 Prompt for AI Agents
In view/app/login/page.tsx around line 47 the logout flow omits invalidating the
FeatureFlags API cache, which can leave stale feature flags after logout; update
the logout logic to dispatch
FeatureFlagsApi.util.invalidateTags(['FeatureFlags']) when handling logout, or
add FeatureFlagsApi to the list passed into resetApiStates so the FeatureFlags
cache is cleared alongside other APIs.
Hey @shresthashim thanks for the PR, Could you please attach recording of working solution, Thanks! |
hey @raghavyuva due to some issues, i am unable to provide you the recording. If that works, you can merge this PR, else you can inform me the problem that may occur. |
hey @raghavyuva due to some issues, i am unable to provide you the recording. If that works, you can merge this PR, else you can inform me the problem that may occur. |
hey can you review and respond please ? |
The review might take some time as we have to test this behavior before merging, Thank you for being patient, Feel free to pick up new issues available if looking for hacktoberfest which are quick enough to merge, Or kindly provide with the screen recordings to speed up the procedure thanks! |
Yeah...due to some issues, i am unable to record the solution if it works, merge it otherwise share the problem with me |
Can you provide what issues you are facing while recording the solution? That might solve it, code review alone cannot confirm the behavior as we have to ensure it works properly |
yeah i mean not to review only the code please do it and if it works merge this pr |
Issue : #461
Fix for Feature Disabled Issue on Login
Problem
After logging out and logging back in without clearing browser cache, users were seeing a "Feature Disabled" screen instead of the dashboard, even when they should have access.
Root Cause
RTK Query's feature flags cache wasn't being invalidated on login, causing stale cached data from previous sessions to persist and show incorrect feature states.
Solution
Modified the login page (
view/app/login/page.tsx
) to invalidate the feature flags cache immediately after successful authentication:FeatureFlagsApi
dispatch(FeatureFlagsApi.util.invalidateTags(['FeatureFlags']))
after setting credentials in both regular login and 2FA login flowsFiles Changed
view/app/login/page.tsx
: Added cache invalidation on loginTesting
To test:
This ensures fresh feature flag data is fetched on each login, preventing cache-related access issues.
Summary by CodeRabbit