melhorias em validar token
This commit is contained in:
parent
e0a492f7d2
commit
947ffdc815
6 changed files with 13 additions and 16 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import type { tipoResposta } from "p-respostas"
|
||||
import { respostaComuns, type tipoResposta } from "p-respostas"
|
||||
|
||||
type tipoPostValidarTokem = { token: string }
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ export const validarToken = async ({
|
|||
}: {
|
||||
base_url_autenticacao: string
|
||||
post: tipoPostValidarTokem
|
||||
}): Promise<"valido" | "erro"> => {
|
||||
}): Promise<tipoResposta<string>> => {
|
||||
const url = `${site_autenticacao(base_url_autenticacao)}/api/validar_token`
|
||||
|
||||
try {
|
||||
|
|
@ -23,13 +23,11 @@ export const validarToken = async ({
|
|||
})
|
||||
.then((r) => r.json())
|
||||
.then((r) => r as tipoResposta<any>)
|
||||
.then((resposta) =>
|
||||
resposta.eCerto ? ("valido" as const) : ("erro" as const),
|
||||
)
|
||||
.catch(() => "erro" as const)
|
||||
|
||||
.catch((err) => respostaComuns.erro(`Erro: ${(err as Error).message}`))
|
||||
|
||||
return resposta
|
||||
} catch (_e) {
|
||||
return "erro"
|
||||
} catch (err) {
|
||||
return respostaComuns.erro(`Erro: ${(err as Error).message}`)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue