-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Ajusta testes para as modificações feitas na autenticação de us…
…uário
- Loading branch information
1 parent
108ec04
commit 44254c4
Showing
3 changed files
with
30 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { authGuard } from "@/guards/authGuard"; | ||
|
||
const apiUrl = process.env.VUE_APP_API_URL; | ||
|
||
// Função para autenticar o usuário | ||
export async function autenticaUsuario(emailEntrada, senhaEntrada) { | ||
try { | ||
const resposta = await fetch(`${apiUrl}/autenticar`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ email: emailEntrada, senha: senhaEntrada }), | ||
}); | ||
if (!resposta.ok) { | ||
throw new Error(`Erro ao autenticar usuário: ${resposta.statusText}`); | ||
} | ||
const data = await resposta.json(); | ||
if (data.success) { | ||
authGuard(true, data.matricula); | ||
return true; | ||
} else { | ||
authGuard(false); | ||
return false; | ||
} | ||
} catch (erro) { | ||
throw new Error(`Erro ao autenticar usuário: ${erro.message}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters