@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.js CHANGED
@@ -923,9 +923,14 @@ function AuthProvider({
923
923
  if (typeof window === 'undefined') return;
924
924
  const handleStorageChange = event => {
925
925
  if (event.key === 'auth:logout') {
926
- window.location.reload();
926
+ // Limpa o user do store - a aplicação redireciona automaticamente quando user é null
927
+ useAuthStore.setState({
928
+ user: null,
929
+ currentSession: null,
930
+ sessions: []
931
+ });
927
932
  }
928
- // Se o token mudou em outra aba, recarrega
933
+ // Se o token mudou em outra aba, verifica validade
929
934
  if (event.key === 'auth:token') {
930
935
  checkTokenValidity();
931
936
  }
@@ -941,8 +946,6 @@ function AuthProvider({
941
946
  });
942
947
  // Dispara evento de logout para sincronizar entre abas
943
948
  localStorage.setItem('auth:logout', Date.now());
944
- // Recarrega para redirecionar - deixa o Protect/rotas decidirem para onde ir
945
- window.location.reload();
946
949
  };
947
950
  window.addEventListener('storage', handleStorageChange);
948
951
  window.addEventListener('auth:session-revoked', handleSessionRevoked);