function ajax_login(url,condicao,metodo,assicrono,propriedade){ if (window.XMLHttpRequest){ // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else{ // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } var assicrono = assicrono ? assicrono : false; if(assicrono == true){ xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ if (eval('typeof ' + propriedade) == 'function') { propriedade(xmlhttp.responseText); } else { propriedade = xmlhttp.responseText; } } } } if (condicao.length > 0) { condicao+= "&sid="+Math.random(); } if (window.location.href.indexOf('https://aplicacoes.mds.gov.br/sagi/') === 0 && url.indexOf('https://www.mds.gov.br/sagissl/') === 0) { url = url.replace('https://www.mds.gov.br/sagissl/','https://aplicacoes.mds.gov.br/sagi/'); } xmlhttp.open(metodo,url+'?'+condicao,assicrono); if(assicrono == false){ xmlhttp.send(null); if (propriedade){ propriedade(xmlhttp.responseText); }else{ return xmlhttp.responseText; } }else{ xmlhttp.send(); } } var login_externo; var path_web = "https://aplicacoes.mds.gov.br/sagi/autenticacao/"; var usuario_digitando_ativo; var pesquisa_usuario; var confirma_senha; var dados_sistema; var autenticado_sistema = false; var url_atual = window.location.href; if (url_atual.match(".mds.gov.br") && (dados_sistema = ajax_login(path_web+"loginusuario_saa.php","sistema_cadastrado="+encodeURIComponent(url_atual),"GET",false)) != "false") { function getCookie(c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i 2 && email.value.indexOf("@") < 0)) { carrega_formulario(true); var status = ''; usuario_digitando_ativo = setTimeout("verifica_login_saa();",400); } else { document.getElementById("tipo_login").innerHTML = ""; document.getElementById("areacadastro").style.display="none"; //document.getElementById("areasenha").style.display="none"; document.getElementById("areaconfirmasenha").style.display="none"; document.getElementById("camposenha").value=""; document.getElementById("campoconfirmasenha").value=""; ativa_label(document.getElementById("camposenha")); ativa_label(document.getElementById("campoconfirmasenha")); campo_senha_vermelho(true); confirma_senha = false; faz_validacao = true; //document.getElementById("areaesqueciasenha").style.display="none"; //document.getElementById("areaenviar").style.display="none"; document.getElementById("areaopenid").style.display="none"; } } function dispara_usuario_digitando(variavel,e) { setTimeout( function () { if (variavel.value.length > 1 && (e == 8 || e > 45)) { usuario_digitando_login(); } pesquisa_usuario = variavel.value; } ,100); } var valor; function verifica_login() { if (document.getElementById("campousuario").value == pesquisa_usuario) { setTimeout( function () { carrega_formulario(true); ajax_login(path_web+"loginusuario_saa.php","email="+document.getElementById("campousuario").value+"&checklogin=1","GET",true,status_autenticacao); } ,1); } } function verifica_login_saa() { if (document.getElementById("campousuario").value == pesquisa_usuario) { setTimeout( function () { carrega_formulario(true); ajax_login(path_web+"loginusuario_saa.php","authsaa_login="+document.getElementById("campousuario").value+"&checklogin=1","GET",true,status_autenticacao); } ,1); } } function status_autenticacao(valor) { document.getElementById("mensagem").innerHTML = " "; if (valor && valor.indexOf(".") > 0) //match(/^(\d\.)/)) { var status = valor.substr(0,valor.indexOf(".")); valor = valor.substr(valor.indexOf(".")+1); } document.getElementById("areaesqueciasenha").style.display="block"; if (status == '0') //CADASTRAR NOVO USUÁRIO { setTimeout('document.getElementById("tipo_login").innerHTML+= " (Novo cadastro)"',10); document.getElementById("areacadastro").style.display="block"; document.getElementById("areaesqueciasenha").style.display="none"; document.getElementById("areaemail").style.display="none"; document.getElementById("areaopenid").style.display="none"; document.getElementById("areaconfirmasenha").style.display="block"; faz_validacao = true; } function muda_camposecretaria() { var mudacamposecretaria = document.getElementById("campos_orgao_secretaria").firstChild; mudacamposecretaria.style.display = "none"; mudacamposecretaria.nextSibling.id = ""; mudacamposecretaria.nextSibling.style.display = "none"; mudacamposecretaria.nextSibling.nextSibling.id = "camposecretaria"; mudacamposecretaria.nextSibling.nextSibling.style.display = ""; } function muda_camporgao() { var mudacamposecretaria = document.getElementById("campos_orgao_secretaria").firstChild; if (mudacamposecretaria.nextSibling.value == "") { mudacamposecretaria.style.display = "block"; } mudacamposecretaria.nextSibling.id = "camposecretaria"; mudacamposecretaria.nextSibling.style.display = ""; mudacamposecretaria.nextSibling.nextSibling.id = ""; mudacamposecretaria.nextSibling.nextSibling.style.display = "none"; } switch(valor) { case '0': document.getElementById("areasenha").style.display="block"; document.getElementById("tipo_login").innerHTML = "Novo Usuário"; confirma_senha = true; muda_camporgao(); break; case '1': document.getElementById("areasenha").style.display="block"; document.getElementById("areaconfirmasenha").style.display="none"; document.getElementById("camposenha").previousSibling.innerHTML = "Senha"; document.getElementById("areaesqueciasenha").style.display="none"; document.getElementById("tipo_login").innerHTML = "Usuário MDS"; campo_senha_vermelho(true); confirma_senha = false; muda_camposecretaria(); break; case "2": document.getElementById("areasenha").style.display="block"; document.getElementById("camposenha").previousSibling.innerHTML = "Senha"; document.getElementById("areaconfirmasenha").style.display="none"; document.getElementById("tipo_login").innerHTML = "Login SAGI"; confirma_senha = false; muda_camporgao(); break; case "2a": document.getElementById("camposenha").previousSibling.innerHTML = "Senha"; document.getElementById("areaconfirmasenha").style.display="none"; document.getElementById("tipo_login").innerHTML = "Login SAGI"; document.getElementById("areacadastro").style.display="none"; document.getElementById("areasenha").style.display="none"; setTimeout(function(){document.getElementById("areaenviar").style.display="none";},10); confirma_senha = false; muda_camporgao(); document.getElementById("mensagem").innerHTML = "
Usuário encontra-se desativado, clique no botão abaixo para receber e-mail de ativação.
Atenção: O envio de e-mail pode demorar alguns minutos! Verifique sua Caixa de SPAM/Junk/Lixo Eletrônico!

Se o e-mail de ativação não chegar, enviar um e-mail para aiad.sagi@cidadania.gov.br, com o assunto 'Ativar o meu cadastro', informando o seu nome e o seu cpf!
"; break; case "6": document.getElementById("areacadastro").style.display="none"; document.getElementById("areasenha").style.display="block"; document.getElementById("camposenha").previousSibling.innerHTML = "Senha SAA"; document.getElementById("areaconfirmasenha").style.display="none"; document.getElementById("areaesqueciasenha").style.display="none"; document.getElementById("tipo_login").innerHTML = "Usuário SAA"; campo_senha_vermelho(true); confirma_senha = false; //muda_camporgao(); break; default: document.getElementById("tipo_login").innerHTML = ""; document.getElementById("areacadastro").style.display="none"; document.getElementById("areasenha").style.display="none"; document.getElementById("areaconfirmasenha").style.display="none"; document.getElementById("areaesqueciasenha").style.display="none"; document.getElementById("areaenviar").style.display="none"; document.getElementById("areaopenid").style.display=""; campo_senha_vermelho(true); confirma_senha = false; faz_validacao = true; } if (status == '1') //USUÁRIO JÁ EXISTE { document.getElementById("tipo_login").innerHTML = document.getElementById("tipo_login").innerHTML.replace(" (Novo cadastro)",""); document.getElementById("areacadastro").style.display="none"; document.getElementById("areaopenid").style.display="none"; document.getElementById("areaemail").style.display="none"; campo_senha_vermelho(true); confirma_senha = false; } carrega_formulario(); } function carrega_formulario(chave) { if (chave) { document.getElementById('arealoading').style.display="block"; document.getElementById("areaenviar").style.display="none"; } else { document.getElementById('arealoading').style.display="none"; document.getElementById("areaenviar").style.display="block"; } } function mostra_tela_login(campo) { if (campo.nextSibling.style.display=="block") { if (!document.getElementById("campousuario").disabled) { campo.nextSibling.style.visibility="hidden"; } campo.nextSibling.style.display="none"; } else { campo.nextSibling.style.display="block"; campo.nextSibling.style.visibility="visible"; if (!document.getElementById("campousuario").disabled) { document.getElementById("campousuario").focus(); } } } function esconde_tela_login() { document.getElementById("mensagem").innerHTML = " "; document.getElementById("tipo_login").innerHTML = ""; document.getElementById("tipo_login").style.width=""; document.getElementById("tipo_login").style.textAlign=""; document.getElementById("tipo_login").style.marginLeft="6%"; document.getElementById("tipo_login").nextSibling.style.display=""; document.getElementById("arealoading").nextSibling.onclick(); document.getElementById('campousuario').disabled = false; document.getElementById("campousuario").value = document.getElementById("camponome").value = document.getElementById("campocpf").value = document.getElementById("camposecretaria").value = document.getElementById("camposenha").value = document.getElementById("campoconfirmasenha").value = ""; document.getElementById("campocpf").nextSibling.style.display = "none"; ativa_label(document.getElementById("camponome")); ativa_label(document.getElementById("campocpf")); ativa_label(document.getElementById("camposecretaria")); ativa_label(document.getElementById("camposenha")); ativa_label(document.getElementById("campoconfirmasenha")); document.getElementById("areacadastro").style.display="none"; // document.getElementById("areasenha").style.display="none"; document.getElementById("areaconfirmasenha").style.display="none"; document.getElementById("areaesqueciasenha").style.display="none"; document.getElementById("areaenviar").firstChild.value="Enviar"; document.getElementById("areaenviar").style.display="none"; document.getElementById("areaopenid").style.display=""; } function carrega_login() { var tamanho_campo = "style='width: 97%;'"; var scripts = document.getElementsByTagName("script"); for(var i=0; i < scripts.length;i++) { if (scripts[i].src.match("loginusuario_saa.php")) { scripts = scripts[i]; break; } } var layout_antigo = (document.getElementById('tema') == null && document.getElementById('rodape-tema') == null) ? true : false; var barra_login = document.createElement("div"); barra_login.style.top = ""; barra_login.id = "barra_authsagi"; if (scripts.parentNode.tagName.toLowerCase() != "head") { scripts.parentNode.insertBefore(barra_login,scripts); } else { if (layout_antigo) { document.getElementsByTagName("body")[0].insertBefore(barra_login,document.getElementsByTagName("body")[0].firstChild.nextSibling); } else { document.getElementById('tema').parentNode.insertBefore(barra_login,document.getElementById('tema')); } } if (layout_antigo) { var fileref=document.createElement("link"); fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", path_web+"css/login_usuario_layantigo.css?sid="+Math.random()); document.getElementsByTagName("head")[0].appendChild(fileref); } else { barra_login.style.position = "relative"; } let redirect = window.location.href; var url_login_legado_mc = new Array('https://aplicacoes.mds.gov.br/sagi/atendimento/auth/index.php'); var url_login_legado_sagi = new Array('https://aplicacoes.mds.gov.br/sagi/sima_capacitacao/index.php','https://aplicacoes.mds.gov.br/sagi/dicivip_datain/pg_principal.php'); var display_login_legado = ""; var url_login_novo = ""; if(url_login_legado_mc.indexOf(redirect) != -1) { url_login_novo = ""; display_login_legado = "style='display: none !important;'"; } if(url_login_legado_sagi.indexOf(redirect) != -1) { url_login_novo = ""; display_login_legado = "style='display: none !important;'"; } barra_login.innerHTML += ""+ "
"+ "
"+ ""+ "
"+ "
"+ ""+ ""+url_login_novo+ "
"+ "
"+ "
"; if ((!autenticado_sistema || pedisenha_saa) && document.getElementById("authsagi_login") != null) { var nova_posicao_login = document.getElementById("authsagi_login"); //Clica no botão login document.getElementById('arealoading').nextSibling.onclick(); document.getElementById('arealogin').style.position = "absolute"; document.getElementById('arealoading').nextSibling.style.display = "none"; var top_exato = parseInt(nova_posicao_login.offsetTop-nova_posicao_login.offsetHeight); var left_exato = nova_posicao_login.offsetLeft; while(nova_posicao_login.parentNode.tagName.toLowerCase() != "body") { nova_posicao_login = nova_posicao_login.parentNode; if (nova_posicao_login.offsetTop > 0) { top_exato+= nova_posicao_login.offsetTop; left_exato+= nova_posicao_login.offsetLeft; break; } } document.getElementById('arealogin').style.top = (top_exato-20)+"px"; document.getElementById('arealogin').style.left = (left_exato+20)+"px"; document.getElementById('tipo_login').style.marginTop = "-22px"; } if (pedisenha_saa) { alert("Por favor, digite sua senha do SAA.\n Em caso de dúvidas, envie email para: rede.suas@cidadania.gov.br"); document.getElementById("areasenha").style.display="block"; document.getElementById("camposenha").previousSibling.innerHTML = "Entre com sua senha do SAA"; document.getElementById("camposenha").style.width = "97%"; document.getElementById("campousuario").value = getCookie("authsagi_cpf"); document.getElementById("campousuario").previousSibling.style.display="none"; //document.getElementById("campousuario").style.display="none"; document.getElementById("campousuario").disabled = true; document.getElementById("areacadastro").style.display="none"; document.getElementById("areaconfirmasenha").style.display="none"; document.getElementById("areaesqueciasenha").style.display="none"; document.getElementById("areaenviar").firstChild.value="Enviar"; document.getElementById("areaenviar").style.display="block"; document.getElementById("areaenviar").innerHTML = document.getElementById("areaenviar").innerHTML + ""; document.getElementById("areaopenid").style.display="none"; if (document.getElementById("authsagi_login") == null) { document.getElementById('arealoading').nextSibling.onclick(); } setTimeout("document.getElementById('camposenha').focus()",500); } } var faz_validacao = true; function valida_campos() { var msg = ""; if (document.getElementById("campousuario").value == "") { msg+="Login do usuário\n"; } if (document.getElementById("areacadastro").style.display != "none") { if (document.getElementById("camponome").value == "") { msg+="Nome\n"; } if (document.getElementById("campocpf").value.length < 14 || (document.getElementById("campocpf").value.length == 14 && document.getElementById("campocpf").nextSibling.style.display != "none" && document.getElementById("campocpf").nextSibling.lastChild.style.display == "inline")) { msg+="CPF\n"; } if (document.getElementById("camposecretaria").value == "" || document.getElementById("camposecretaria").value == "0") { //msg+= (document.getElementById("camposecretaria").tagName.toLowerCase() == "input") ? "Orgão\n" : "Secretaria\n"; } } if (document.getElementById("areasenha").style.display != "none" && document.getElementById("camposenha").value == "") { msg+="Senha\n"; } if (document.getElementById("areasenha").style.display != "none" && document.getElementById("areaconfirmasenha").style.display != "none" && document.getElementById("camposenha").value != document.getElementById("campoconfirmasenha").value) { msg+="Confirma Senha\n"; } if (msg != "") { faz_validacao = false; alert("Preencha ou corrija o(s) campo(s):\n\n"+msg); setTimeout("faz_validacao = true",100); return false; } return true; } function validaEmail(email,e) { exp = /^[\w-]+(\.[\w-]+)*@(([\w-]{2,63}\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/; if(exp.test(email)) { faz_validacao = true; return true; } faz_validacao = false; if (e == 13) { alert("Por favor, forneça um e-mail válido"); } } function alerta(valor) { alert(valor); } function autenticacao(valor) { if (document.getElementById("areacadastro").style.display != "none") { if (valor && valor.match(/^(\d\.)/)) { var status = valor.substr(0,1); valor = valor.substr(2); } if (status == "0") { switch(valor) { case "1": alert("Senha ou usuário inválido\npara realizar o cadastro!"); break; } setTimeout("faz_validacao = true",100); return false; } else { if (valor != null && !valor.match("e-mail de confirma")) { alert(valor); } } } //Não autentica quando cadastra e ainda não confirmou cadastro if (valor != null && valor.match("e-mail de confirma")) { setTimeout("esconde_tela_login()",5000); alert(valor); window.location.href = window.location.href; return true; } //AUTENTICA var campo_login = document.getElementById("campousuario").value; if ((is_numeric(campo_login) && campo_login.length == 11) || (campo_login.length > 2 && campo_login.indexOf("@") < 0)) { var result = ajax_login(path_web+"loginusuario_saa.php","autenticar=1&authsaa_login="+document.getElementById("campousuario").value+"&senha="+encodeURIComponent(document.getElementById("camposenha").value)+"&authsaa=1&id_url_saa="+authsagi_id_url_saa,"GET",false); } else { var result = ajax_login(path_web+"loginusuario_saa.php","autenticar=1&email="+document.getElementById("campousuario").value+"&senha="+encodeURIComponent(document.getElementById("camposenha").value)+"&authsaa="+(pedisenha_saa ? "1" : "")+"&id_url_saa="+authsagi_id_url_saa,"GET",false); } if (result.indexOf("502 ") > 0) { alert("Erro de autenticação, por favor tente usar outro navegador de internet. Em breve este problema será corrigido!"); setTimeout("faz_validacao = true",100); return false; } if (result.toLowerCase().indexOf("erro ") > 0) { alert(result); setTimeout("faz_validacao = true",100); return false; } if (result.indexOf("Autenticando Usuário SAA") > -1) { window.location.href = window.location.href; } if (result.length > 0 && !(result.indexOf("Erro")==0)) { usuario_autenticado(result); return true; } resultado = result.replace("Erro ",""); resultado = (resultado.length > 0) ? result : "Usuário e/ou senha incorretos"; alert("Falha ao autenticar!\n"+resultado); setTimeout("faz_validacao = true",100); return false; } function usuario_cadastrando(email,nome) { status_autenticacao("0.3"); document.getElementById("campousuario").value = email; document.getElementById("camponome").value = nome; document.getElementById("camponome").onfocus(); document.getElementById("camponome").onblur(); document.getElementById("areacadastro").style.display=""; document.getElementById("areasenha").style.display="none"; document.getElementById("areaesqueciasenha").style.display="none"; document.getElementById("areaenviar").style.display=""; document.getElementById("areaenviar").firstChild.value="Finalizar Cadastro"; setTimeout("document.getElementById('arealoading').nextSibling.onclick();document.getElementById('campousuario').onfocus();document.getElementById('campousuario').disabled = true;document.getElementById('camponome').onfocus();",500); } var auth_lista_subusuarios; var auth_lista_subusuarios_invalidos var auth_pagina_auth; var auth_status_autenticacao; function usuario_autenticado(email) { document.getElementById("tipo_login").innerHTML = "
"+email+" | editar login | sair"; document.getElementById("tipo_login").style.width="390px"; document.getElementById("tipo_login").style.textAlign="right"; document.getElementById("tipo_login").style.marginLeft=""; document.getElementById("tipo_login").nextSibling.style.display="none"; document.getElementById('campousuario').disabled = false; document.getElementById("campousuario").value = document.getElementById("camponome").value = document.getElementById("campocpf").value = document.getElementById("camposecretaria").value = document.getElementById("camposenha").value = ""; document.getElementById("areacadastro").style.display="none"; document.getElementById("areasenha").style.display="none"; document.getElementById("areaconfirmasenha").style.display="none"; document.getElementById("areaesqueciasenha").style.display="none"; document.getElementById("areaenviar").firstChild.value="Enviar"; document.getElementById("areaenviar").style.display="none"; if (!arguments[1]) { window.location.href = window.location.href; } } function usuario_desconectado() { ajax_login(path_web+"loginusuario_saa.php","deletacookie=1&url="+encodeURIComponent(url_atual),"GET",false, desloga); deleta_cookies(); faz_validacao = true; location.reload(); } var fecha_iframe; function desloga() { alert('O usuário foi desconectado'); window.location.href = window.location.href; setTimeout(function () { window.location.href = window.location.href; },5000); } function ativa_label(campo,e) { if (campo.value != "") { if (campo.previousSibling != null) { campo.previousSibling.style.display="none"; } if (document.getElementById('areaenviar').style.display != "none" && faz_validacao && e == 13) { document.getElementById("areaenviar").firstChild.style.backgroundColor = "#FF4800"; setTimeout('document.getElementById("areaenviar").firstChild.style.backgroundColor = "";',200); if (document.getElementById("areaemail").style.display != "none") { var resultado = ajax_login(path_web+"loginusuario_saa.php","autenticar=1&authsaa=email&email="+document.getElementById("campoemail").value,"GET",false); if (resultado == "false") { window.location.href = window.location.href; } if (resultado != "Erro") { window.location.href = window.location.href; } } if (valida_campos()) { faz_validacao = false; if (document.getElementById("areacadastro").style.display != "none") { //CADASTRA ajax_login(path_web+"loginusuario_saa.php","cadastrar=1&email="+document.getElementById("campousuario").value+"&nome="+document.getElementById("camponome").value+"&cpf="+document.getElementById("campocpf").value+"&secretaria="+document.getElementById("camposecretaria").value+"&senha="+encodeURIComponent(document.getElementById("camposenha").value)+"&retorno="+window.location.href,"GET",true,autenticacao); } else { var email = document.getElementById("campousuario"); // AUTENTICAÇÃO GERAL // autenticacao(); } } } } else { campo.previousSibling.style.display="block"; } } function esqueceu_senha(email) { if (email != null) { var resultado = ajax_login(path_web+"loginusuario_saa.php","troca_senha=1&email="+email+"&retorno="+window.location.href,"GET",false); if (resultado == 1) { alert("Um e-mail foi enviado para "+email+" com instruções para recuperação de senha.\nCaso ocorra uma demora no recebimento do e-mail, verifique sua caixa de spam!\n\nEm caso de problemas, envie um email para aiad.sagi@cidadania.gov.br ."); } else { alert("Erro ao enviar instruções de recuperação de senha para "+email); } } else { alert("Por favor, preencha o campo e-mail e clique novamente!"); } } var authsagi_func_final; function authsagi_login_finalizado(func) { if (func != null) { authsagi_func_final = func; } if (authsagi_func_final != null) { authsagi_func_final.call(); } } var fileref=document.createElement("script"); fileref.setAttribute("type", "text/javascript"); fileref.setAttribute("src", path_web+"js/loginusuario.js?sid=693"); document.getElementsByTagName("head")[0].appendChild(fileref); addEvent_login(window, "load", carrega_login); }else{ // alert('Sistema de autenticacao fora do ar. Favor tentar novamente em alguns minutos.'); // window.location="https://aplicacoes.mds.gov.br/sagi/"; }