diff options
Diffstat (limited to 'spring-boot/10-role-based-security/src/main/resources/templates')
5 files changed, 77 insertions, 1 deletions
diff --git a/spring-boot/10-role-based-security/src/main/resources/templates/error.html b/spring-boot/10-role-based-security/src/main/resources/templates/error.html new file mode 100644 index 0000000..ea5a329 --- /dev/null +++ b/spring-boot/10-role-based-security/src/main/resources/templates/error.html @@ -0,0 +1,12 @@ +<!DOCTYPE html> +<html xmlns:th="http://thymeleaf.org"> +<head> + <title>Error Occurred</title> +</head> +<body> + <h1>An error occurred!</h1> + <p>Status: <span th:text="${status}">500</span></p> + <p>Message: <span th:text="${message}">Error Message</span></p> + <p>Timestamp: <span th:text="${timestamp}">Date</span></p> +</body> +</html>
\ No newline at end of file diff --git a/spring-boot/10-role-based-security/src/main/resources/templates/error/403.html b/spring-boot/10-role-based-security/src/main/resources/templates/error/403.html new file mode 100644 index 0000000..c1db2c0 --- /dev/null +++ b/spring-boot/10-role-based-security/src/main/resources/templates/error/403.html @@ -0,0 +1,12 @@ +<!DOCTYPE html> +<html xmlns:th="http://thymeleaf.org"> +<head> + <title>Error Occurred</title> +</head> +<body> + <h1>You have no permission!</h1> + <p>Status: <span th:text="${status}">500</span></p> + <p>Message: <span th:text="${message}">Error Message</span></p> + <p>Timestamp: <span th:text="${timestamp}">Date</span></p> +</body> +</html>
\ No newline at end of file diff --git a/spring-boot/10-role-based-security/src/main/resources/templates/layout/main.html b/spring-boot/10-role-based-security/src/main/resources/templates/layout/main.html index df96fc5..0b20361 100644 --- a/spring-boot/10-role-based-security/src/main/resources/templates/layout/main.html +++ b/spring-boot/10-role-based-security/src/main/resources/templates/layout/main.html @@ -18,7 +18,7 @@ <ul> <li><a th:href="@{/}">Home</a></li> <li><a th:href="@{/contact}">Contact Us</a></li> - <li sec:authorize="hasRole('ADMIN')"><a th:href="@{/admin}">Admin</a></li> + <li sec:authorize="hasRole('ADMIN')"><a th:href="@{/security/users}">Users</a></li> <li sec:authorize="isAuthenticated()"><a th:href="@{/profile/{name}(name=${#authentication.name})}">Profile</a></li> <li sec:authorize="isAuthenticated()"><a th:href="@{/logout}">Logout</a></li> </ul> diff --git a/spring-boot/10-role-based-security/src/main/resources/templates/security/user-form.html b/spring-boot/10-role-based-security/src/main/resources/templates/security/user-form.html new file mode 100644 index 0000000..a27ae7d --- /dev/null +++ b/spring-boot/10-role-based-security/src/main/resources/templates/security/user-form.html @@ -0,0 +1,22 @@ +<!DOCTYPE HTML> +<html xmlns:th="http://www.thymeleaf.org" + th:replace="~{layout/main :: layout(title='User', content=~{::main})}"> + +<body> + <main> + <form th:action="@{/security/user/update}" th:object="${userForm}" method="post"> + <!-- Hidden field binds the "id" property seamlessly --> + <input type="hidden" th:field="*{id}" /> + + <div class="form-field-container"> + <label>Description</label> + <textarea th:field="*{description}" placeholder="Description"></textarea> + <div class="validation-error" th:if="${#fields.hasErrors('description')}" th:errors="*{description}"></div> + </div> + + <button type="submit">Save</button> + </form> + </main> +</body> + +</html>
\ No newline at end of file diff --git a/spring-boot/10-role-based-security/src/main/resources/templates/security/users.html b/spring-boot/10-role-based-security/src/main/resources/templates/security/users.html new file mode 100644 index 0000000..81752c8 --- /dev/null +++ b/spring-boot/10-role-based-security/src/main/resources/templates/security/users.html @@ -0,0 +1,30 @@ +<!DOCTYPE HTML> +<html xmlns:th="http://www.thymeleaf.org" + th:replace="~{layout/main :: layout(title='Users', content=~{::main})}"> + +<body> + <main> + <table> + <thead> + <tr> + <th>ID</th> + <th>Username</th> + <th>Description</th> + <th>Edit</th> + </tr> + </thead> + <tbody> + <!-- th:each loops over the "userss" list sent by the controller --> + <tr th:each="user : ${users}"> + <!-- th:text updates the cell contents dynamically --> + <td th:text="${user.id}">1</td> + <td th:text="${user.username}">Username</td> + <td th:text="${user.description}">User description</td> + <td><a th:href="@{/security/user/update/{id}(id=${user.id})}">Edit</a></td> + </tr> + </tbody> + </table> + </main> +</body> + +</html>
\ No newline at end of file |
