fix: prevent private memos from disappearing during token refresh (#5565)

Root cause: enabled={isInitialized && !!user} prevented displaying cached
data when user auth state transitioned during token refresh.

Changes:
- Remove !!user check from Home page enabled condition
- Add clearAccessToken() in redirectOnAuthFailure for clean logout

Fixes #5565
pull/5573/head
Steven 4 months ago
parent 8770b186e4
commit 6db58fae11

@ -28,7 +28,7 @@ const Home = () => {
listSort={listSort}
orderBy={orderBy}
filter={memoFilter}
enabled={isInitialized && !!user} // Wait for contexts to stabilize before fetching
enabled={isInitialized}
/>
</div>
);

@ -1,3 +1,4 @@
import { clearAccessToken } from "@/auth-state";
import { getInstanceConfig } from "@/instance-config";
import { ROUTES } from "@/router/routes";
@ -31,6 +32,10 @@ export function redirectOnAuthFailure(): void {
// Only redirect if it's a private route or disallowPublicVisibility is enabled
if (disallowPublicVisibility || isPrivateRoute(currentPath)) {
// Clear access token to ensure user is fully logged out
// This prevents the issue where user appears logged in but sees only public memos
// See: https://github.com/usememos/memos/issues/5565
clearAccessToken();
window.location.replace(target);
}
}

Loading…
Cancel
Save