Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 1 addition & 37 deletions src/main/resources/html/site/index.html
Original file line number Diff line number Diff line change
@@ -1,37 +1 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Login</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Login</h1>
<form id="loginForm">
<label for="username">Benutzername:</label>
<input type="text" id="username" name="username" required><br><br>
<label for="password">Passwort:</label>
<input type="password" id="password" name="password" required><br><br>
<button type="submit">Anmelden</button>
</form>

<script>
document.getElementById("loginForm").addEventListener("submit", async (e) => {
e.preventDefault();

let formData = new FormData(e.target);
let response = await fetch("/login", {
method: "POST",
body: new URLSearchParams(formData),
credentials: "include"
});

if (response.ok) {
window.location.href = "/dashboard";
} else {
alert("Falsches Passwort!");
}
});
</script>
</body>
</html>
%{login}%
38 changes: 1 addition & 37 deletions src/main/resources/html/site/login.html
Original file line number Diff line number Diff line change
@@ -1,37 +1 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Login</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Login</h1>
<form id="loginForm">
<label for="username">Benutzername:</label>
<input type="text" id="username" name="username" required><br><br>
<label for="password">Passwort:</label>
<input type="password" id="password" name="password" required><br><br>
<button type="submit">Anmelden</button>
</form>

<script>
document.getElementById("loginForm").addEventListener("submit", async (e) => {
e.preventDefault();

let formData = new FormData(e.target);
let response = await fetch("/login", {
method: "POST",
body: new URLSearchParams(formData),
credentials: "include"
});

if (response.ok) {
window.location.href = "/dashboard";
} else {
alert("Falsches Passwort!");
}
});
</script>
</body>
</html>
%{login}%
101 changes: 101 additions & 0 deletions src/main/resources/templates/html/login.html
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, we need a little script to override the form behavior, you can look here:

<script>
document.getElementById("loginForm").addEventListener("submit", async (e) => {
e.preventDefault();
let formData = new FormData(e.target);
let response = await fetch("/login", {
method: "POST",
body: new URLSearchParams(formData),
credentials: "include"
});
if (response.ok) {
window.location.href = "/dashboard";
} else {
alert("Falsches Passwort!");
}
});
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login</title>

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<style>
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
background-color: #f5f7fb;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.login-container {
background: #ffffff;
padding: 32px;
border-radius: 8px;
width: 100%;
max-width: 360px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

h2 {
text-align: center;
margin-bottom: 24px;
color: #333;
}

label {
display: block;
margin-bottom: 6px;
font-weight: 600;
color: #444;
}

input {
width: 100%;
padding: 10px;
margin-bottom: 16px;
border-radius: 4px;
border: 1px solid #ccc;
font-size: 14px;
}

button {
width: 100%;
padding: 10px;
background-color: #3f51b5;
color: #ffffff;
border: none;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
}

button:hover {
background-color: #303f9f;
}
</style>
</head>
<body>

<div class="login-container">
<h2>Login</h2>

<form id = "loginForm" method="post" action="/login">
<label for="username">Username</label>
<input id="username" name="username" type="text" required>

<label for="password">Password</label>
<input id="password" name="password" type="password" required>

<button type="submit">Login</button>
</form>
</div>
<script>
document.getElementById("loginForm").addEventListener("submit", async (e) => {
e.preventDefault();

let formData = new FormData(e.target);
let response = await fetch("/login", {
method: "POST",
body: new URLSearchParams(formData),
credentials: "include"
});

if (response.ok) {
window.location.href = "/dashboard";
} else {
alert("Falsches Passwort!");
}
});
</script>
</body>
</html>
Loading