Skip to content

Conversation

shresthashim
Copy link

@shresthashim shresthashim commented Oct 7, 2025

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:

  • Added import for FeatureFlagsApi
  • Added dispatch(FeatureFlagsApi.util.invalidateTags(['FeatureFlags'])) after setting credentials in both regular login and 2FA login flows

Files Changed

  • view/app/login/page.tsx: Added cache invalidation on login

Testing

To test:

  1. Log in to the application
  2. Log out
  3. Log in again (without clearing cache)
  4. Verify dashboard loads normally without "Feature Disabled" screen

This ensures fresh feature flag data is fetched on each login, preventing cache-related access issues.

Summary by CodeRabbit

  • Bug Fixes
    • After successful login (including two-factor), the app now refreshes feature availability so the dashboard immediately reflects the latest options.
    • Prevents stale feature states after authentication, eliminating the need to manually refresh or re-login for new features to appear.
    • Users should now consistently see correct feature toggles and access levels right after entry.

Copy link
Contributor

coderabbitai bot commented Oct 7, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Login 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

Cohort / File(s) Summary of changes
Login flow & FeatureFlags cache invalidation
view/app/login/page.tsx
Imported FeatureFlagsApi. On successful login and successful 2FA login, dispatches FeatureFlagsApi.util.invalidateTags(['FeatureFlags']) before navigating to /dashboard. No other logic modified.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

nixopus-view

Suggested reviewers

  • zhravan

Poem

A hop, a bop, I cache and drop,
Flags refreshed—no stale old crop.
Tokens in paw, I bound ahead,
To dashboards bright, with carrots spread.
Thump-thump! The features sing—
Fresh as spring in everything. 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely describes the main fix—preventing the “Feature Disabled” screen from appearing after logout and login—making it directly aligned with the PR’s purpose.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 57e3ff8 and 9672246.

📒 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']));
Copy link
Contributor

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:

  1. 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.

  2. Tag name: Confirm that 'FeatureFlags' matches the tag defined in FeatureFlagsApi to ensure the invalidation targets the correct cache.

  3. 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.

@raghavyuva
Copy link
Owner

Hey @shresthashim thanks for the PR,

Could you please attach recording of working solution,

Thanks!

@zhravan zhravan changed the base branch from master to feat/develop October 7, 2025 12:19
@shresthashim
Copy link
Author

shresthashim commented Oct 8, 2025

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 possible, can you please test the code modifications that i did yourself.
I have only few lines of code. You can test it in a minute.

If that works, you can merge this PR, else you can inform me the problem that may occur.

@shresthashim shresthashim reopened this Oct 8, 2025
@shresthashim
Copy link
Author

hey @raghavyuva due to some issues, i am unable to provide you the recording.
If possible, can you please test the code modifications that i did yourself.
I have only few lines of code. You can test it in a minute.

If that works, you can merge this PR, else you can inform me the problem that may occur.

@shresthashim
Copy link
Author

Hey @shresthashim thanks for the PR,

Could you please attach recording of working solution,

Thanks!

hey can you review and respond please ?

@raghavyuva
Copy link
Owner

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!

@shresthashim
Copy link
Author

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
i have changed only few lines of code which you can test it yourself and review

if it works, merge it otherwise share the problem with me

@raghavyuva
Copy link
Owner

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

@shresthashim
Copy link
Author

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
i have changed only 2 3 lines of code which you can do the same in your code and test it yourself

please do it and if it works merge this pr
if it doesn't share me the issue

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.

3 participants