fix(DevWeb): Correct redirection from login

This commit is contained in:
Lucàs
2024-03-21 14:56:37 +01:00
parent bb9f1caee6
commit 1e02ad373c
4 changed files with 110 additions and 84 deletions
@@ -1,7 +1,8 @@
const loginForm = document.getElementById("loginForm");
const loginForm = document.getElementById("login-form");
loginForm.addEventListener("submit", (event) => {
event.preventDefault();
const formData = new FormData(loginForm);
const data = {};
formData.forEach((value, key) => data[key] = value);
@@ -17,7 +18,7 @@ loginForm.addEventListener("submit", (event) => {
.then(res => res.json())
.then(data => {
console.log(data);
if (data.status === 200) window.location.href = data.redirect;
// if (data.status === 200) window.location.href = data.redirect;
})
.catch(error => console.error("Error:", error))
;
@@ -3,7 +3,6 @@
<html>
<head>
<title>Login</title>
<script defer type="text/javascript"><%@include file="../static/js/login.js" %></script>
<style><%@include file="../static/css/login.css" %></style>
</head>
<body>
@@ -15,7 +14,7 @@
<div class="flex-column login-gap">
<div>
<h1>Login</h1>
<form id="login-form" action="${pageContext.request.contextPath}/login" method="POST">
<form id="login-form" action="${pageContext.request.contextPath}/api/auth/login" method="POST">
<label id="username-label" for="username">Username:</label>
<input type="text" id="username" name="username" required>
@@ -36,5 +35,7 @@
</section>
</main>
<script defer type="text/javascript"><%@include file="../static/js/login.js" %></script>
</body>
</html>