@riligar/auth-react 1.20.2 → 1.20.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -920,9 +920,14 @@ function AuthProvider({
920
920
  if (typeof window === 'undefined') return;
921
921
  const handleStorageChange = event => {
922
922
  if (event.key === 'auth:logout') {
923
- window.location.reload();
923
+ // Limpa o user do store - a aplicação redireciona automaticamente quando user é null
924
+ useAuthStore.setState({
925
+ user: null,
926
+ currentSession: null,
927
+ sessions: []
928
+ });
924
929
  }
925
- // Se o token mudou em outra aba, recarrega
930
+ // Se o token mudou em outra aba, verifica validade
926
931
  if (event.key === 'auth:token') {
927
932
  checkTokenValidity();
928
933
  }
@@ -938,8 +943,6 @@ function AuthProvider({
938
943
  });
939
944
  // Dispara evento de logout para sincronizar entre abas
940
945
  localStorage.setItem('auth:logout', Date.now());
941
- // Recarrega para redirecionar - deixa o Protect/rotas decidirem para onde ir
942
- window.location.reload();
943
946
  };
944
947
  window.addEventListener('storage', handleStorageChange);
945
948
  window.addEventListener('auth:session-revoked', handleSessionRevoked);