Added basic login and logout functionality

- update SecurityConfiguration
  - add logout
  - add login
- add AuthenticationController
- add goodbye.html
- add logout.html
- add login.html
This commit is contained in:
2025-01-15 12:41:32 +01:00
parent b812f835ab
commit 3bd6f3b5af
5 changed files with 93 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Goodbye</title>
<!--/*/<th:block th:insert="~{layout.html :: documentHead}"/>/*/-->
</head>
<body>
<main>
<h1>You are logged out</h1>
<hr>
<p>We hope to see you again soon!</p>
<a th:href="@{/login}">Login Again</a>
</main>
<!--/*/<th:block th:replace="~{layout.html :: script}"/>/*/-->
</body>
</html>

View File

@@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Login</title>
<!--/*/<th:block th:insert="~{layout.html :: documentHead}"/>/*/-->
</head>
<body>
<main>
<h1>Login</h1>
<hr>
<form id="loginForm" th:action="@{/login}" th:method="post">
<label for="username" >Username</label>
<input type="text" id="username" name="username" placeholder="Enter your username" required>
<br>
<label for="password">Password</label>
<input type="password" id="password" name="password" placeholder="Enter your password" required>
<br>
<button type="submit">Login</button>
</form>
</main>
<!--/*/<th:block th:replace="~{layout.html :: script}"/>/*/-->
</body>
</html>

View File

@@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Logout</title>
<!--/*/<th:block th:insert="~{layout.html :: documentHead}"/>/*/-->
</head>
<body>
<main>
<h1>Logout</h1>
<hr>
<p>Are you sure you want to logout?</p>
<form id="logoutForm" th:action="@{/logout}" th:method="post"></form>
<button type="submit" onclick="document.getElementById('logoutForm').submit(); return false;">Logout</button>
</main>
<!--/*/<th:block th:replace="~{layout.html :: script}"/>/*/-->
</body>
</html>