🩹(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.
This commit is contained in:
@@ -44,7 +44,7 @@ export function useAuthQuery(
|
|||||||
staleTime: 1000 * 60 * 15, // 15 minutes
|
staleTime: 1000 * 60 * 15, // 15 minutes
|
||||||
retry: (failureCount, error) => {
|
retry: (failureCount, error) => {
|
||||||
// we assume that a 401 means the user is not logged in
|
// we assume that a 401 means the user is not logged in
|
||||||
if (error.status == 401) {
|
if (error.status === 401) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return failureCount < DEFAULT_QUERY_RETRY;
|
return failureCount < DEFAULT_QUERY_RETRY;
|
||||||
|
|||||||
@@ -176,10 +176,7 @@ const DocPage = ({ id }: DocProps) => {
|
|||||||
|
|
||||||
if (error.status === 401) {
|
if (error.status === 401) {
|
||||||
if (authenticated) {
|
if (authenticated) {
|
||||||
queryClient.setQueryData([KEY_AUTH], {
|
queryClient.setQueryData([KEY_AUTH], null);
|
||||||
user: null,
|
|
||||||
authenticated: false,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
setAuthUrl();
|
setAuthUrl();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user