Skip to content

Commit b91840c

Browse files
committed
🩹(frontend) set correctly query data when 401
When receiving a 401 error, we should set the auth query data to null, not to an object with user: null and authenticated: false. This ensures that components relying on the auth state can correctly interpret the unauthenticated status.
1 parent a9b77fb commit b91840c

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/frontend/apps/impress/src/features/auth/api/useAuthQuery.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function useAuthQuery(
4444
staleTime: 1000 * 60 * 15, // 15 minutes
4545
retry: (failureCount, error) => {
4646
// we assume that a 401 means the user is not logged in
47-
if (error.status == 401) {
47+
if (error.status === 401) {
4848
return false;
4949
}
5050
return failureCount < DEFAULT_QUERY_RETRY;

src/frontend/apps/impress/src/pages/docs/[id]/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,7 @@ const DocPage = ({ id }: DocProps) => {
176176

177177
if (error.status === 401) {
178178
if (authenticated) {
179-
queryClient.setQueryData([KEY_AUTH], {
180-
user: null,
181-
authenticated: false,
182-
});
179+
queryClient.setQueryData([KEY_AUTH], null);
183180
}
184181
setAuthUrl();
185182
}

0 commit comments

Comments
 (0)