Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions .changeset/giant-coats-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@refinedev/core": patch
---

- Invalidate queries on logout.
- Resolves cached error state being there after login from forced logout.

[Resolves #6944](https://github.com/refinedev/refine/issues/6997)
4 changes: 4 additions & 0 deletions packages/core/src/contexts/auth/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { type PropsWithChildren } from "react";

import type { IAuthContext } from "./types";
import { useQueryClient } from "@tanstack/react-query";

export const AuthProviderContext = React.createContext<Partial<IAuthContext>>(
{},
Expand All @@ -9,6 +10,8 @@ export const AuthProviderContext = React.createContext<Partial<IAuthContext>>(
export const AuthProviderContextProvider: React.FC<
PropsWithChildren<IAuthContext>
> = ({ children, isProvided, ...authProvider }) => {
const queryClient = useQueryClient();

const handleLogin = async (params: unknown) => {
try {
const result = await authProvider.login?.(params);
Expand Down Expand Up @@ -40,6 +43,7 @@ export const AuthProviderContextProvider: React.FC<
const handleLogout = async (params: unknown) => {
try {
const result = await authProvider.logout?.(params);
queryClient.invalidateQueries();

return result;
} catch (error) {
Expand Down
Loading