Skip to content

Commit

Permalink
Update login
Browse files Browse the repository at this point in the history
  • Loading branch information
guisilvas committed Jun 30, 2024
1 parent 1cf3e71 commit d121884
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions codigo/assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,34 @@ function checkLogin() {
}
}

// Função para limpar dados de login
function clearLoginData() {
localStorage.removeItem('token');
localStorage.removeItem('userLogado');
localStorage.removeItem('loginChecked');
}

// Função para pingar o servidor
function pingServer() {
fetch('/ping')
.then(response => {
if (!response.ok) {
throw new Error('Server not responding');
}
setTimeout(pingServer, 5000); // Tentar novamente após 5 segundos
})
.catch(error => {
console.error('Ping failed, clearing login data:', error);
clearLoginData();
});
}

// Adiciona evento ao carregar a página
window.addEventListener('load', () => {
checkLogin();
pingServer(); // Inicia o ping no servidor
});

// Função para carregar as notícias após o login
function loadNews() {
const noticiasContainer = document.querySelector('.row');
Expand Down

0 comments on commit d121884

Please sign in to comment.