<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorator="layout">
<head>
	<title>Secured Content</title>
</head>
<body>
	<div layout:fragment="content">
		<h1>Secured Page</h1>
		<p>This page is secured using Spring Boot, Spring Session, and Spring Security.</p>

		<p>Your current session id is <span id="session-id" th:text="${#httpSession.id}"></span></p>

		<table class="table table-stripped">
			<tr>
				<th>Id Suffix</th>
				<th>Location</th>
				<th>Created</th>
				<th>Last Updated</th>
				<th>Information</th>
				<th>Terminate</th>
			</tr>
			<tr th:each="sessionElement : ${sessions}" th:with="details=${sessionElement.getAttribute('SESSION_DETAILS')}">
				<td th:text="${sessionElement.id.substring(30)}"></td>
				<td th:text="${details.location}"></td>
				<td th:text="${#dates.format(new java.util.Date(sessionElement.creationTime),'dd/MMM/yyyy HH:mm:ss')}"></td>
				<td th:text="${#dates.format(new java.util.Date(sessionElement.lastAccessedTime),'dd/MMM/yyyy HH:mm:ss')}"></td>
				<td th:text="${details.accessType}"></td>
				<td>
					<form th:action="@{'/sessions/' + ${sessionElement.id}}" th:method="delete">
						<input th:id="'terminate-' + ${sessionElement.id}" type="submit" value="Terminate" th:disabled="${sessionElement.id == #httpSession.id}"/>
					</form>
				</td>
			</tr>
		</table>
	</div>
</body>
</html>
