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
This commit is contained in:
parent
8770b186e4
commit
6db58fae11
2 changed files with 6 additions and 1 deletions
|
|
@ -28,7 +28,7 @@ const Home = () => {
|
||||||
listSort={listSort}
|
listSort={listSort}
|
||||||
orderBy={orderBy}
|
orderBy={orderBy}
|
||||||
filter={memoFilter}
|
filter={memoFilter}
|
||||||
enabled={isInitialized && !!user} // Wait for contexts to stabilize before fetching
|
enabled={isInitialized}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { clearAccessToken } from "@/auth-state";
|
||||||
import { getInstanceConfig } from "@/instance-config";
|
import { getInstanceConfig } from "@/instance-config";
|
||||||
import { ROUTES } from "@/router/routes";
|
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
|
// Only redirect if it's a private route or disallowPublicVisibility is enabled
|
||||||
if (disallowPublicVisibility || isPrivateRoute(currentPath)) {
|
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);
|
window.location.replace(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue