diff --git a/src/components/dashboard/WorkflowTarefas.tsx b/src/components/dashboard/WorkflowTarefas.tsx index aaf6b15..714d3a5 100644 --- a/src/components/dashboard/WorkflowTarefas.tsx +++ b/src/components/dashboard/WorkflowTarefas.tsx @@ -7,6 +7,11 @@ interface Tarefa { status: string; } +function isValidJWT(token?: string) { + // JWT tem 3 partes separadas por ponto e cada parte deve ser base64 + return !!token && token.split('.').length === 3; +} + export const WorkflowTarefas: React.FC = () => { const { token } = useAuth(); const [tarefas, setTarefas] = useState([]); @@ -15,6 +20,11 @@ export const WorkflowTarefas: React.FC = () => { useEffect(() => { async function fetchTarefas() { + if (!isValidJWT(token)) { + setError('Token de autenticação inválido ou ausente. Faça login novamente.'); + setLoading(false); + return; + } try { setLoading(true); setError(null);