37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.pAutenticacao = void 0;
|
|
const urlAutenticacao = (ambiente) => `${ambiente == "producao"
|
|
? "https://carro-de-boi.idz.one"
|
|
: "http://localhost:5030"}/autenticacao`;
|
|
/** faz a validação do token */
|
|
const validarToken = async ({ ambiente, post, buscar, }) => {
|
|
const url = `${urlAutenticacao(ambiente)}/autenticacao/api/validar_token`;
|
|
try {
|
|
const resposta = await buscar(url, post)
|
|
.then((resposta) => resposta.eCerto ? "valido" : "erro")
|
|
.catch((e) => "erro");
|
|
return resposta;
|
|
}
|
|
catch (e) {
|
|
return "erro";
|
|
}
|
|
};
|
|
const codigoPrefeituraSite = async ({ ambiente, post, buscar, }) => {
|
|
const url = `${urlAutenticacao(ambiente)}/autenticacao/api/codigo_prefeitura_site`;
|
|
try {
|
|
const resposta = await buscar(url, post)
|
|
.then((resposta) => resposta.eCerto ? "valido" : "erro")
|
|
.catch((e) => "erro");
|
|
return resposta;
|
|
}
|
|
catch (e) {
|
|
return "erro";
|
|
}
|
|
};
|
|
/** todas as rotas de comunicação com autenticador partem dessa variável */
|
|
exports.pAutenticacao = {
|
|
validarToken,
|
|
urlAutenticacao,
|
|
codigoPrefeituraSite,
|
|
};
|