2023-08-13 01:12:29 +01:00
|
|
|
<!DOCTYPE html>
|
2024-05-22 21:48:23 +01:00
|
|
|
<html th:lang="${#locale.language}" th:dir="#{language.direction}" th:data-language="${#locale.toString()}" xmlns:th="https://www.thymeleaf.org">
|
2024-02-16 22:49:06 +01:00
|
|
|
<head>
|
|
|
|
<th:block th:insert="~{fragments/common :: head(title=#{adminUserSettings.title}, header=#{adminUserSettings.header})}"></th:block>
|
|
|
|
</head>
|
2023-08-13 01:12:29 +01:00
|
|
|
|
2024-02-16 22:49:06 +01:00
|
|
|
<body>
|
2023-08-13 01:12:29 +01:00
|
|
|
<th:block th:insert="~{fragments/common :: game}"></th:block>
|
|
|
|
<div id="page-container">
|
2024-02-16 22:49:06 +01:00
|
|
|
<div id="content-wrap">
|
|
|
|
<th:block th:insert="~{fragments/navbar.html :: navbar}"></th:block>
|
2024-03-21 21:58:01 +01:00
|
|
|
<br><br>
|
2024-02-16 22:49:06 +01:00
|
|
|
<div class="container">
|
|
|
|
<div class="row justify-content-center">
|
2024-07-04 23:13:03 +02:00
|
|
|
<div class="col-md-9 bg-card">
|
|
|
|
<div class="tool-header">
|
|
|
|
<span class="material-symbols-rounded tool-header-icon organize">manage_accounts</span>
|
|
|
|
<span class="tool-header-text" th:text="#{adminUserSettings.header}">Admin User Control Settings</span>
|
|
|
|
</div>
|
2024-02-11 11:47:00 -05:00
|
|
|
|
2024-02-16 22:49:06 +01:00
|
|
|
<!-- User Settings Title -->
|
2024-06-07 23:27:16 +02:00
|
|
|
<div style="background: var(--md-sys-color-outline-variant);padding: .8rem; margin: 10px 0; border-radius: 2rem; text-align: center;">
|
|
|
|
<a href="#" data-bs-toggle="modal" data-bs-target="#addUserModal" class="btn btn-outline-info" th:title="#{adminUserSettings.addUser}">
|
|
|
|
<span class="material-symbols-rounded">person_add</span>
|
|
|
|
<span th:text="#{adminUserSettings.addUser}">Add New User</span>
|
|
|
|
</a>
|
|
|
|
<a href="#" data-bs-toggle="modal" data-bs-target="#changeUserRoleModal" class="btn btn-outline-info" th:title="#{adminUserSettings.changeUserRole}">
|
|
|
|
<span class="material-symbols-rounded">edit</span>
|
|
|
|
<span th:text="#{adminUserSettings.changeUserRole}">Change User's Role</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
2024-05-18 23:47:05 +02:00
|
|
|
<div th:if="${deleteMessage}" class="alert alert-danger">
|
|
|
|
<span th:text="#{${deleteMessage}}">Message</span>
|
2024-03-06 23:14:02 +01:00
|
|
|
</div>
|
2024-07-04 23:13:03 +02:00
|
|
|
<div class="bg-card mt-3 mb-3">
|
|
|
|
<table class="table table-striped table-hover">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th scope="col">UID</th>
|
|
|
|
<th scope="col" th:text="#{username}">Username</th>
|
|
|
|
<th scope="col" th:text="#{adminUserSettings.roles}">Roles</th>
|
|
|
|
<th scope="col" th:text="#{adminUserSettings.actions}">Actions</th>
|
|
|
|
<th scope="col" th:text="#{adminUserSettings.authenticated}">Authenticated</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr th:each="user : ${users}">
|
|
|
|
<th scope="row" style="align-content: center;" th:text="${user.id}"></th>
|
|
|
|
<td style="align-content: center;" th:text="${user.username}"></td>
|
|
|
|
<td style="align-content: center;" th:text="#{${user.roleName}}"></td>
|
|
|
|
<td style="align-content: center;">
|
|
|
|
<form th:if="${user.username != currentUsername}" th:action="@{'/api/v1/user/admin/deleteUser/' + ${user.username}}" method="post" onsubmit="return confirmDelete()">
|
|
|
|
<button type="submit" th:title="#{adminUserSettings.deleteUser}" class="btn btn-info"><span class="material-symbols-rounded">person_remove</span></button>
|
|
|
|
</form>
|
|
|
|
<a th:if="${user.username == currentUsername}" th:href="@{'/account'}" class="btn btn-outline-info"><span class="material-symbols-rounded">edit</span></a>
|
|
|
|
</td>
|
|
|
|
<td style="align-content: center;" th:text="${user.authenticationType}"></td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<script th:inline="javascript">
|
|
|
|
const confirm_text = /*[[#{adminUserSettings.confirmDeleteUser}]]*/ 'Should the user be deleted?';
|
|
|
|
function confirmDelete() {
|
|
|
|
return confirm(confirm_text);
|
|
|
|
}
|
|
|
|
</script>
|
2024-06-07 23:27:16 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-08-13 01:12:29 +01:00
|
|
|
|
2024-06-07 23:27:16 +02:00
|
|
|
<!-- change User role Modal start -->
|
|
|
|
<div class="modal fade" id="changeUserRoleModal" tabindex="-1" aria-labelledby="changeUserRoleModalLabel" aria-hidden="true">
|
|
|
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h2 th:text="#{adminUserSettings.changeUserRole}">Change User's Role</h2>
|
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
|
|
|
|
<span class="material-symbols-rounded">
|
|
|
|
close
|
|
|
|
</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<button class="btn btn-outline-info" data-toggle="tooltip" data-placement="auto" th:title="#{downgradeCurrentUserLongMessage}" th:text="#{help}">Help</button>
|
|
|
|
<div th:if="${changeMessage}" class="alert alert-danger">
|
|
|
|
<span th:text="#{${changeMessage}}">Default message if not found</span>
|
2024-02-16 22:49:06 +01:00
|
|
|
</div>
|
2024-06-07 23:27:16 +02:00
|
|
|
<form th:action="@{'/api/v1/user/admin/changeRole'}" method="post">
|
2024-02-16 22:49:06 +01:00
|
|
|
<div class="mb-3">
|
|
|
|
<label for="username" th:text="#{username}">Username</label>
|
2024-06-07 23:27:16 +02:00
|
|
|
<select name="username" class="form-control" required>
|
|
|
|
<option value="" disabled selected th:text="#{selectFillter}">-- Select --</option>
|
|
|
|
<option th:each="user : ${users}" th:if="${user.username != currentUsername}" th:value="${user.username}" th:text="${user.username}">Username</option>
|
|
|
|
</select>
|
2024-02-16 22:49:06 +01:00
|
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
|
|
<label for="role" th:text="#{adminUserSettings.role}">Role</label>
|
|
|
|
<select name="role" class="form-control" required>
|
2024-05-02 14:52:50 -06:00
|
|
|
<option value="" disabled selected th:text="#{selectFillter}">-- Select --</option>
|
2024-03-06 23:14:02 +01:00
|
|
|
<option th:each="roleDetail : ${roleDetails}" th:value="${roleDetail.key}" th:text="#{${roleDetail.value}}">Role</option>
|
2024-02-16 22:49:06 +01:00
|
|
|
</select>
|
|
|
|
</div>
|
2023-08-13 01:12:29 +01:00
|
|
|
|
2024-05-02 14:52:50 -06:00
|
|
|
<!-- Add other fields as required -->
|
|
|
|
<button type="submit" class="btn btn-primary" th:text="#{adminUserSettings.submit}">Save User</button>
|
|
|
|
</form>
|
2024-06-07 23:27:16 +02:00
|
|
|
</div>
|
|
|
|
<div class="modal-footer"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- change User role Modal end -->
|
|
|
|
|
|
|
|
<!-- Add User Modal start -->
|
|
|
|
<div class="modal fade" id="addUserModal" tabindex="-1" aria-labelledby="addUserModalLabel" aria-hidden="true">
|
|
|
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h5 class="modal-title" id="addUserModalLabel" th:text="#{adminUserSettings.addUser}">Add New User</h5>
|
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
|
|
|
|
<span class="material-symbols-rounded">
|
|
|
|
close
|
|
|
|
</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<div th:if="${addMessage}" class="alert alert-danger">
|
|
|
|
<span th:text="#{${addMessage}}">Default message if not found</span>
|
2024-05-02 14:52:50 -06:00
|
|
|
</div>
|
2024-06-07 23:27:16 +02:00
|
|
|
<button class="btn btn-outline-info" data-toggle="tooltip" data-placement="auto" th:title="#{adminUserSettings.usernameInfo}" th:text="#{help}">Help</button>
|
|
|
|
<form id="formsaveuser" th:action="@{'/api/v1/user/admin/saveUser'}" method="post">
|
2024-05-02 14:52:50 -06:00
|
|
|
<div class="mb-3">
|
|
|
|
<label for="username" th:text="#{username}">Username</label>
|
2024-06-07 23:27:16 +02:00
|
|
|
<input type="text" class="form-control" name="username" id="username" th:title="#{adminUserSettings.usernameInfo}" required>
|
|
|
|
<span id="usernameError" style="display: none;" th:text="#{invalidUsernameMessage}">Invalid username!</span>
|
|
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
|
|
<label for="password" th:text="#{password}">Password</label>
|
|
|
|
<input type="password" class="form-control" name="password" required>
|
2024-05-02 14:52:50 -06:00
|
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
|
|
<label for="role" th:text="#{adminUserSettings.role}">Role</label>
|
|
|
|
<select name="role" class="form-control" required>
|
|
|
|
<option value="" disabled selected th:text="#{selectFillter}">-- Select --</option>
|
|
|
|
<option th:each="roleDetail : ${roleDetails}" th:value="${roleDetail.key}" th:text="#{${roleDetail.value}}">Role</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
2024-06-07 23:27:16 +02:00
|
|
|
<div class="form-check mb-3">
|
|
|
|
<input type="checkbox" class="form-check-input" id="forceChange" name="forceChange">
|
|
|
|
<label class="form-check-label" for="forceChange" th:text="#{adminUserSettings.forceChange}">Force user to change username/password on login</label>
|
|
|
|
</div>
|
2024-02-16 22:49:06 +01:00
|
|
|
<button type="submit" class="btn btn-primary" th:text="#{adminUserSettings.submit}">Save User</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
2024-06-07 23:27:16 +02:00
|
|
|
<div class="modal-footer"></div>
|
2024-02-16 22:49:06 +01:00
|
|
|
</div>
|
2023-08-13 01:12:29 +01:00
|
|
|
</div>
|
2024-02-16 22:49:06 +01:00
|
|
|
</div>
|
2024-06-07 23:27:16 +02:00
|
|
|
<!-- Add User Modal end -->
|
|
|
|
|
2024-05-02 14:52:50 -06:00
|
|
|
<script th:inline="javascript">
|
2024-05-18 23:47:05 +02:00
|
|
|
jQuery.validator.addMethod("usernamePattern", function(value, element) {
|
|
|
|
return this.optional(element) || /^[a-zA-Z0-9][a-zA-Z0-9@._+-]*[a-zA-Z0-9]$|^(?=.{1,64}@)[A-Za-z0-9]+(\.[A-Za-z0-9_+.-]+)*@[^-][A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,})$/.test(value);
|
|
|
|
}, /*[[#{invalidUsernameMessage}]]*/ "Invalid username format");
|
2024-05-02 14:52:50 -06:00
|
|
|
$(document).ready(function() {
|
2024-05-18 23:47:05 +02:00
|
|
|
$('[data-toggle="tooltip"]').tooltip();
|
|
|
|
|
|
|
|
$('#formsaveuser').validate({
|
|
|
|
rules: {
|
|
|
|
username: {
|
|
|
|
required: true,
|
|
|
|
usernamePattern: true
|
|
|
|
},
|
|
|
|
password: {
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
messages: {
|
|
|
|
username: {
|
|
|
|
usernamePattern: /*[[#{invalidUsernameMessage}]]*/ "Invalid username format"
|
|
|
|
},
|
|
|
|
},
|
|
|
|
errorPlacement: function(error, element) {
|
|
|
|
if (element.attr("name") === "username") {
|
|
|
|
$("#usernameError").text(error.text()).show();
|
|
|
|
} else {
|
|
|
|
error.insertAfter(element);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
success: function(label, element) {
|
|
|
|
if ($(element).attr("name") === "username") {
|
|
|
|
$("#usernameError").hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#username').on('input', function() {
|
|
|
|
var usernameInput = $(this);
|
|
|
|
var isValid = usernameInput[0].checkValidity();
|
|
|
|
var errorSpan = $('#usernameError');
|
|
|
|
|
|
|
|
if (isValid) {
|
|
|
|
usernameInput.removeClass('invalid').addClass('valid');
|
|
|
|
errorSpan.hide();
|
|
|
|
} else {
|
|
|
|
usernameInput.removeClass('valid').addClass('invalid');
|
|
|
|
errorSpan.show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2024-05-02 14:52:50 -06:00
|
|
|
</script>
|
2024-02-16 22:49:06 +01:00
|
|
|
<th:block th:insert="~{fragments/footer.html :: footer}"></th:block>
|
2023-08-13 01:12:29 +01:00
|
|
|
</div>
|
2024-06-07 23:27:16 +02:00
|
|
|
<div th:if="${oAuth2Enabled}" class="modal fade" id="editUserModal" tabindex="-1" role="dialog" aria-labelledby="editUserModalLabel" aria-hidden="true">
|
|
|
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h5 class="modal-title" id="editUserModalLabel" th:text="#{login.ssoSignIn}"></h5>
|
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
|
|
|
|
<span class="material-symbols-rounded">
|
|
|
|
close
|
|
|
|
</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<div class="mb-3" th:each="provider : ${providerlist}">
|
|
|
|
<a th:href="@{|/oauth2/authorization/${provider.key}|}" th:text="${provider.value}" class="w-100 btn btn-lg btn-primary">OpenID Connect</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" th:text="#{close}"></button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-02-16 22:49:06 +01:00
|
|
|
</body>
|
2024-03-21 21:58:01 +01:00
|
|
|
</html>
|