Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions view/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { toast } from 'sonner';
import { AuthResponse } from '@/redux/types/user';
import { useDispatch, useSelector } from 'react-redux';
import { setCredentials } from '@/redux/features/users/authSlice';
import { FeatureFlagsApi } from '@/redux/services/feature-flags/featureFlagsApi';
import { RootState } from '@/redux/store';

export default function LoginPage() {
Expand Down Expand Up @@ -43,6 +44,7 @@ export default function LoginPage() {
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.

router.push('/dashboard');
}
} catch (error) {
Expand All @@ -63,6 +65,7 @@ export default function LoginPage() {
expiresIn: response.expires_in
})
);
dispatch(FeatureFlagsApi.util.invalidateTags(['FeatureFlags']));
router.push('/dashboard');
}
} catch (error) {
Expand Down