mirror of https://github.com/kortix-ai/suna.git
Merge pull request #1061 from kubet/fix/refresh-token-timing
fix: user reset
This commit is contained in:
commit
06e10831fb
|
@ -43,7 +43,13 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
|
|||
const { data: authListener } = supabase.auth.onAuthStateChange(
|
||||
async (event, newSession) => {
|
||||
setSession(newSession);
|
||||
|
||||
// Only update user state on actual auth events, not token refresh
|
||||
if (event === 'SIGNED_IN' || event === 'SIGNED_OUT') {
|
||||
setUser(newSession?.user ?? null);
|
||||
}
|
||||
// For TOKEN_REFRESHED events, keep the existing user state
|
||||
|
||||
if (isLoading) setIsLoading(false);
|
||||
if (event === 'SIGNED_IN' && newSession?.user) {
|
||||
await checkAndInstallSunaAgent(newSession.user.id, newSession.user.created_at);
|
||||
|
|
Loading…
Reference in New Issue