Added login page

This commit is contained in:
neviyn 2021-04-30 12:27:40 +01:00
parent 4cf91146db
commit 1f43e53a83
2 changed files with 54 additions and 0 deletions

View File

@ -27,6 +27,13 @@ class BaseController
return "landing" return "landing"
} }
@GetMapping("/login")
fun login(model: Model, error: String?, logout: String?): String? {
if (error != null) model.addAttribute("error", "Your username and password is invalid.")
if (logout != null) model.addAttribute("message", "You have been logged out successfully.")
return "login"
}
} }
@Controller @Controller

View File

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta th:replace="fragments :: header"/>
<title>Login</title>
</head>
<body>
<div class="container">
<div class="row justify-content-center mt-3">
<div class="col text-center">
<h2 class="display-3">Welcome back</h2>
</div>
</div>
<div class="row justify-content-center mt-3">
<div class="col-8 text-center">
<form class="form-sign_in" method="POST" th:action="@{/login}">
<div class="form-group mt-3">
<span th:text="${message}"></span>
<div class="form-floating mb-3">
<input autofocus class="form-control form-control-lg" id="username" name="username" type="text">
<label for="username">Username</label>
</div>
<div class="form-floating mb-3">
<input class="form-control form-control-lg" id="password" name="password" type="password">
<label for="password">Password</label>
</div>
<div class="mb-3">
<span class="has-error text-danger" th:text="${error}"></span>
<input name="${_csrf.parameterName}" type="hidden" value="${_csrf.token}"/>
<div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Log In</button>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="row justify-content-center mt-3">
<div class="col text-center">
<a class="btn btn-secondary btn-lg" href="/" role="button">Home</a>
</div>
</div>
</div>
</body>
</html>