deleted api post request and replaced with self written function from database.js.

Also deleted login-auth from docker compose, but not the folder (we can later work on this again).
This commit is contained in:
2025-07-04 20:59:15 +02:00
parent d82998c52d
commit bee18a1ffe
2 changed files with 24 additions and 36 deletions

View File

@@ -33,27 +33,15 @@ app.get("/", (req, res) => {
res.render("index.ejs", { error: null });
});
app.post("/login", (req, res) => {
app.post("/login", async (req, res) => {
const { username, password } = req.body;
const apiUrl = "http://localhost:4002/login";
axios
.post(apiUrl, { username, password })
.then(function (response) {
if (response.data.loginQuery) {
// If login is successful, redirect to the dashboard
res.render("userView.ejs");
} else {
// If login fails, render the login page with an error message
res.status(404).render("index.ejs", { error: response.data.message });
}
})
.catch(function (error) {
console.error("Error during login:", error);
res
.status(500)
.render("index.ejs", { error: "An error occurred during login." });
});
loginUser(username, password).then((result) => {
if (result.success === true) {
res.render("userView.ejs");
} else {
res.render("index.ejs", { error: result.message });
}
});
});
// error handling code