Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
EtoDoze committed Feb 16, 2025
1 parent d612c43 commit 28588c0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions js/server_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ async function criaruser() {

async function verificarToken() {
const token = localStorage.getItem("auth_token");

console.log("Token encontrado:", token); // Verifique se o token está sendo recuperado corretamente.

if (token) {
Expand All @@ -85,7 +84,11 @@ async function criaruser() {
}
});

if (response.ok) {
if (!response.ok) {
const errorData = await response.json();
console.error("Erro ao buscar o usuário:", errorData.message);
alert(`Erro: ${errorData.message}`); // Mostra o erro de forma visível para o usuário
} else {
const data = await response.json();
console.log("Dados recebidos do servidor:", data); // Verifique o conteúdo de data

Expand All @@ -105,10 +108,10 @@ async function criaruser() {
editor.remove();
}

window.location.href = "index.html"; // Redirecionamento após carregar os dados
} else {
const errorData = await response.json();
console.error("Erro ao buscar o usuário:", errorData.message);
// Evitar o redirecionamento repetido
if (window.location.pathname !== "/index.html") {
window.location.href = "index.html"; // Redirecionamento após carregar os dados
}
}
} catch (err) {
console.error("Erro ao buscar o usuário:", err);
Expand All @@ -120,4 +123,5 @@ async function criaruser() {

// Chama a função assíncrona
verificarToken();


0 comments on commit 28588c0

Please sign in to comment.