.
This commit is contained in:
parent
d1afd7376f
commit
af92778e98
6 changed files with 35 additions and 23 deletions
4
dist-require/autenticacao.d.ts
vendored
4
dist-require/autenticacao.d.ts
vendored
|
|
@ -4,10 +4,12 @@ type tipoPostValidarTokem = {
|
|||
};
|
||||
/** todas as rotas de comunicação com autenticador partem dessa variável */
|
||||
export declare const pAutenticacao: {
|
||||
urlValidarToken: ({ ambiente, post, buscar, }: {
|
||||
validarToken: ({ ambiente, post, buscar, }: {
|
||||
ambiente: "desenvolvimento" | "producao";
|
||||
post: tipoPostValidarTokem;
|
||||
/** função que conecta com a API */
|
||||
buscar: (url: string, post: tipoPostValidarTokem) => Promise<tipoResposta<any>>;
|
||||
}) => Promise<"valido" | "erro">;
|
||||
urlAutenticacao: (ambiente: "desenvolvimento" | "producao") => string;
|
||||
};
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.pAutenticacao = void 0;
|
||||
/** retorna uma url e os parametros que devem ser enviádos */
|
||||
const urlValidarToken = async ({ ambiente, post, buscar, }) => {
|
||||
const url = `${ambiente == "producao"
|
||||
? "https://carro-de-boi.idz.one"
|
||||
: "http://localhost:5030"}/autenticacao/api/validar_token`;
|
||||
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")
|
||||
|
|
@ -17,4 +18,4 @@ const urlValidarToken = async ({ ambiente, post, buscar, }) => {
|
|||
}
|
||||
};
|
||||
/** todas as rotas de comunicação com autenticador partem dessa variável */
|
||||
exports.pAutenticacao = { urlValidarToken };
|
||||
exports.pAutenticacao = { validarToken, urlAutenticacao };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue