add consultaUsuariosexterno
This commit is contained in:
parent
07a656a2b4
commit
9491278d6c
62 changed files with 489 additions and 200 deletions
32
src/autenticacao/_validarToken.ts
Normal file
32
src/autenticacao/_validarToken.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import type { tipoResposta } from "p-respostas"
|
||||
import { urlAutenticacao } from "./_urlAutenticacao"
|
||||
type tipoPostValidarTokem = { token: string }
|
||||
|
||||
/** faz a validação do token */
|
||||
export const validarToken = async ({
|
||||
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"> => {
|
||||
const url = `${urlAutenticacao(ambiente)}/api/validar_token`
|
||||
|
||||
try {
|
||||
const resposta = await buscar(url, post)
|
||||
.then((resposta) =>
|
||||
resposta.eCerto ? ("valido" as const) : ("erro" as const),
|
||||
)
|
||||
.catch(() => "erro" as const)
|
||||
|
||||
return resposta
|
||||
} catch (e) {
|
||||
return "erro"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue