From 5eb6ef6f60a12c15ffe35c9dc97ccb74dd7bbc00 Mon Sep 17 00:00:00 2001 From: ankush210103 Date: Sun, 21 Sep 2025 16:24:16 +0530 Subject: [PATCH] fix(auth): revalidate user on login to fix stale state --- src/lib/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/index.tsx b/src/lib/index.tsx index 4f264df..963c63f 100644 --- a/src/lib/index.tsx +++ b/src/lib/index.tsx @@ -163,10 +163,12 @@ export const useFrappeAuth = (options?: SWRConfiguration): { const login = useCallback(async (credentials:AuthCredentials) => { return auth.loginWithUsernamePassword(credentials) .then((m) => { - getUserCookie() + // THE FIX IS HERE: + // Manually trigger a re-fetch of the user data after login. + updateCurrentUser(); return m }) - }, []) + }, [updateCurrentUser]) // ✅And the dependency is added here const logout = useCallback(async () => { return auth.logout()