Merge pull request #1393 from Stirling-Tools/disableConfigUpdater
resolve admin config with custom path
This commit is contained in:
commit
e11fa01d10
6 changed files with 39 additions and 39 deletions
|
@ -66,46 +66,46 @@ public class UserController {
|
|||
RedirectAttributes redirectAttributes) {
|
||||
|
||||
if (!userService.isUsernameValid(newUsername)) {
|
||||
return new RedirectView("/account?messageType=invalidUsername");
|
||||
return new RedirectView("/account?messageType=invalidUsername",true);
|
||||
}
|
||||
|
||||
if (principal == null) {
|
||||
return new RedirectView("/account?messageType=notAuthenticated");
|
||||
return new RedirectView("/account?messageType=notAuthenticated",true);
|
||||
}
|
||||
|
||||
// The username MUST be unique when renaming
|
||||
Optional<User> userOpt = userService.findByUsername(principal.getName());
|
||||
|
||||
if (userOpt == null || userOpt.isEmpty()) {
|
||||
return new RedirectView("/account?messageType=userNotFound");
|
||||
return new RedirectView("/account?messageType=userNotFound",true);
|
||||
}
|
||||
|
||||
User user = userOpt.get();
|
||||
|
||||
if (user.getUsername().equals(newUsername)) {
|
||||
return new RedirectView("/account?messageType=usernameExists");
|
||||
return new RedirectView("/account?messageType=usernameExists",true);
|
||||
}
|
||||
|
||||
if (!userService.isPasswordCorrect(user, currentPassword)) {
|
||||
return new RedirectView("/account?messageType=incorrectPassword");
|
||||
return new RedirectView("/account?messageType=incorrectPassword",true);
|
||||
}
|
||||
|
||||
if (!user.getUsername().equals(newUsername) && userService.usernameExists(newUsername)) {
|
||||
return new RedirectView("/account?messageType=usernameExists");
|
||||
return new RedirectView("/account?messageType=usernameExists",true);
|
||||
}
|
||||
|
||||
if (newUsername != null && newUsername.length() > 0) {
|
||||
try {
|
||||
userService.changeUsername(user, newUsername);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return new RedirectView("/account?messageType=invalidUsername");
|
||||
return new RedirectView("/account?messageType=invalidUsername",true);
|
||||
}
|
||||
}
|
||||
|
||||
// Logout using Spring's utility
|
||||
new SecurityContextLogoutHandler().logout(request, response, null);
|
||||
|
||||
return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED);
|
||||
return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED,true);
|
||||
}
|
||||
|
||||
@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")
|
||||
|
@ -118,19 +118,19 @@ public class UserController {
|
|||
HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
if (principal == null) {
|
||||
return new RedirectView("/change-creds?messageType=notAuthenticated");
|
||||
return new RedirectView("/change-creds?messageType=notAuthenticated",true);
|
||||
}
|
||||
|
||||
Optional<User> userOpt = userService.findByUsernameIgnoreCase(principal.getName());
|
||||
|
||||
if (userOpt == null || userOpt.isEmpty()) {
|
||||
return new RedirectView("/change-creds?messageType=userNotFound");
|
||||
return new RedirectView("/change-creds?messageType=userNotFound",true);
|
||||
}
|
||||
|
||||
User user = userOpt.get();
|
||||
|
||||
if (!userService.isPasswordCorrect(user, currentPassword)) {
|
||||
return new RedirectView("/change-creds?messageType=incorrectPassword");
|
||||
return new RedirectView("/change-creds?messageType=incorrectPassword",true);
|
||||
}
|
||||
|
||||
userService.changePassword(user, newPassword);
|
||||
|
@ -138,7 +138,7 @@ public class UserController {
|
|||
// Logout using Spring's utility
|
||||
new SecurityContextLogoutHandler().logout(request, response, null);
|
||||
|
||||
return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED);
|
||||
return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED,true);
|
||||
}
|
||||
|
||||
@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")
|
||||
|
@ -151,19 +151,19 @@ public class UserController {
|
|||
HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
if (principal == null) {
|
||||
return new RedirectView("/account?messageType=notAuthenticated");
|
||||
return new RedirectView("/account?messageType=notAuthenticated",true);
|
||||
}
|
||||
|
||||
Optional<User> userOpt = userService.findByUsernameIgnoreCase(principal.getName());
|
||||
|
||||
if (userOpt == null || userOpt.isEmpty()) {
|
||||
return new RedirectView("/account?messageType=userNotFound");
|
||||
return new RedirectView("/account?messageType=userNotFound",true);
|
||||
}
|
||||
|
||||
User user = userOpt.get();
|
||||
|
||||
if (!userService.isPasswordCorrect(user, currentPassword)) {
|
||||
return new RedirectView("/account?messageType=incorrectPassword");
|
||||
return new RedirectView("/account?messageType=incorrectPassword",true);
|
||||
}
|
||||
|
||||
userService.changePassword(user, newPassword);
|
||||
|
@ -171,7 +171,7 @@ public class UserController {
|
|||
// Logout using Spring's utility
|
||||
new SecurityContextLogoutHandler().logout(request, response, null);
|
||||
|
||||
return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED);
|
||||
return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED,true);
|
||||
}
|
||||
|
||||
@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")
|
||||
|
@ -204,7 +204,7 @@ public class UserController {
|
|||
boolean forceChange) {
|
||||
|
||||
if (!userService.isUsernameValid(username)) {
|
||||
return new RedirectView("/addUsers?messageType=invalidUsername");
|
||||
return new RedirectView("/addUsers?messageType=invalidUsername",true);
|
||||
}
|
||||
|
||||
Optional<User> userOpt = userService.findByUsernameIgnoreCase(username);
|
||||
|
@ -212,26 +212,26 @@ public class UserController {
|
|||
if (userOpt.isPresent()) {
|
||||
User user = userOpt.get();
|
||||
if (user != null && user.getUsername().equalsIgnoreCase(username)) {
|
||||
return new RedirectView("/addUsers?messageType=usernameExists");
|
||||
return new RedirectView("/addUsers?messageType=usernameExists",true);
|
||||
}
|
||||
}
|
||||
if (userService.usernameExistsIgnoreCase(username)) {
|
||||
return new RedirectView("/addUsers?messageType=usernameExists");
|
||||
return new RedirectView("/addUsers?messageType=usernameExists",true);
|
||||
}
|
||||
try {
|
||||
// Validate the role
|
||||
Role roleEnum = Role.fromString(role);
|
||||
if (roleEnum == Role.INTERNAL_API_USER) {
|
||||
// If the role is INTERNAL_API_USER, reject the request
|
||||
return new RedirectView("/addUsers?messageType=invalidRole");
|
||||
return new RedirectView("/addUsers?messageType=invalidRole",true);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
// If the role ID is not valid, redirect with an error message
|
||||
return new RedirectView("/addUsers?messageType=invalidRole");
|
||||
return new RedirectView("/addUsers?messageType=invalidRole",true);
|
||||
}
|
||||
|
||||
userService.saveUser(username, password, role, forceChange);
|
||||
return new RedirectView("/addUsers"); // Redirect to account page after adding the user
|
||||
return new RedirectView("/addUsers",true); // Redirect to account page after adding the user
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
|
@ -244,33 +244,33 @@ public class UserController {
|
|||
Optional<User> userOpt = userService.findByUsernameIgnoreCase(username);
|
||||
|
||||
if (!userOpt.isPresent()) {
|
||||
return new RedirectView("/addUsers?messageType=userNotFound");
|
||||
return new RedirectView("/addUsers?messageType=userNotFound",true);
|
||||
}
|
||||
if (!userService.usernameExistsIgnoreCase(username)) {
|
||||
return new RedirectView("/addUsers?messageType=userNotFound");
|
||||
return new RedirectView("/addUsers?messageType=userNotFound",true);
|
||||
}
|
||||
// Get the currently authenticated username
|
||||
String currentUsername = authentication.getName();
|
||||
|
||||
// Check if the provided username matches the current session's username
|
||||
if (currentUsername.equalsIgnoreCase(username)) {
|
||||
return new RedirectView("/addUsers?messageType=downgradeCurrentUser");
|
||||
return new RedirectView("/addUsers?messageType=downgradeCurrentUser",true);
|
||||
}
|
||||
try {
|
||||
// Validate the role
|
||||
Role roleEnum = Role.fromString(role);
|
||||
if (roleEnum == Role.INTERNAL_API_USER) {
|
||||
// If the role is INTERNAL_API_USER, reject the request
|
||||
return new RedirectView("/addUsers?messageType=invalidRole");
|
||||
return new RedirectView("/addUsers?messageType=invalidRole",true);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
// If the role ID is not valid, redirect with an error message
|
||||
return new RedirectView("/addUsers?messageType=invalidRole");
|
||||
return new RedirectView("/addUsers?messageType=invalidRole",true);
|
||||
}
|
||||
User user = userOpt.get();
|
||||
|
||||
userService.changeRole(user, role);
|
||||
return new RedirectView("/addUsers"); // Redirect to account page after adding the user
|
||||
return new RedirectView("/addUsers",true); // Redirect to account page after adding the user
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
|
@ -279,7 +279,7 @@ public class UserController {
|
|||
@PathVariable(name = "username") String username, Authentication authentication) {
|
||||
|
||||
if (!userService.usernameExistsIgnoreCase(username)) {
|
||||
return new RedirectView("/addUsers?messageType=deleteUsernameExists");
|
||||
return new RedirectView("/addUsers?messageType=deleteUsernameExists",true);
|
||||
}
|
||||
|
||||
// Get the currently authenticated username
|
||||
|
@ -287,11 +287,11 @@ public class UserController {
|
|||
|
||||
// Check if the provided username matches the current session's username
|
||||
if (currentUsername.equalsIgnoreCase(username)) {
|
||||
return new RedirectView("/addUsers?messageType=deleteCurrentUser");
|
||||
return new RedirectView("/addUsers?messageType=deleteCurrentUser",true);
|
||||
}
|
||||
invalidateUserSessions(username);
|
||||
userService.deleteUser(username);
|
||||
return new RedirectView("/addUsers");
|
||||
return new RedirectView("/addUsers",true);
|
||||
}
|
||||
|
||||
@Autowired private SessionRegistry sessionRegistry;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<td th:text="#{${user.roleName}}"></td>
|
||||
<td>
|
||||
<form th:if="${user.username != currentUsername}" th:action="@{'/api/v1/user/admin/deleteUser/' + ${user.username}}" method="post">
|
||||
<button type="submit" th:text="#{delete}">Delete</button>
|
||||
<button class="btn btn-danger" type="submit" th:text="#{delete}">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
<td th:text="${user.authenticationType}"></td>
|
||||
|
@ -47,7 +47,7 @@
|
|||
<span th:text="#{${addMessage}}">Default message if not found</span>
|
||||
</div>
|
||||
<button class="btn btn-outline-info" data-toggle="tooltip" data-placement="auto" th:title="#{adminUserSettings.usernameInfo}" th:text="#{help}">Help</button>
|
||||
<form id="formsaveuser" action="/api/v1/user/admin/saveUser" method="post">
|
||||
<form id="formsaveuser" th:action="@{/api/v1/user/admin/saveUser}" method="post">
|
||||
<div class="mb-3">
|
||||
<label for="username" th:text="#{username}">Username</label>
|
||||
<input type="text" class="form-control" name="username" id="username" th:title="#{adminUserSettings.usernameInfo}" required>
|
||||
|
@ -78,7 +78,7 @@
|
|||
<div th:if="${changeMessage}" class="alert alert-danger">
|
||||
<span th:text="#{${changeMessage}}">Default message if not found</span>
|
||||
</div>
|
||||
<form action="/api/v1/user/admin/changeRole" method="post">
|
||||
<form th:action="@{/api/v1/user/admin/changeRole}" method="post">
|
||||
<div class="mb-3">
|
||||
<label for="username" th:text="#{username}">Username</label>
|
||||
<select name="username" class="form-control" required>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<span class="material-symbols-rounded tool-header-icon organize">crop</span>
|
||||
<span class="tool-header-text" th:text="#{crop.header}"></span>
|
||||
</div>
|
||||
<form id="cropForm" action="/api/v1/general/crop" method="post" enctype="multipart/form-data">
|
||||
<form id="cropForm" th:action="@{/api/v1/general/crop}" method="post" enctype="multipart/form-data">
|
||||
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multiple=false, accept='application/pdf')}"></div>
|
||||
<input id="x" type="hidden" name="x">
|
||||
<input id="y" type="hidden" name="y">
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<a href="https://github.com/Stirling-Tools/Stirling-PDF/issues" id="github-button" class="btn btn-primary" target="_blank" th:text="#{error.github}"></a>
|
||||
<a href="https://discord.gg/Cn8pWhQRxZ" id="discord-button" class="btn btn-primary" target="_blank" th:text="#{joinDiscord}"></a>
|
||||
</div>
|
||||
<a href="/" id="home-button" class="home-button btn btn-primary" th:text="#{goHomepage}"></a>
|
||||
<a th:href="@{/}" id="home-button" class="home-button btn btn-primary" th:text="#{goHomepage}"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<script src="js/githubVersion.js"></script>
|
||||
<nav class="navbar navbar-expand-lg">
|
||||
<div class="container ">
|
||||
<a class="navbar-brand" href="/" style="display: flex;">
|
||||
<a class="navbar-brand" th:href="@{/}" style="display: flex;">
|
||||
<img class="main-icon" src="favicon.svg" alt="icon">
|
||||
<span class="icon-text" th:text="${@navBarText}"></span>
|
||||
</a>
|
||||
|
|
|
@ -298,7 +298,7 @@ See https://github.com/adobe-type-tools/cmap-resources
|
|||
<input type="number" id="pageNumber" class="toolbarField" title="Page" value="1" min="1" tabindex="15" data-l10n-id="pdfjs-page-input" autocomplete="off">
|
||||
</span>
|
||||
<span id="numPages" class="toolbarLabel"></span>
|
||||
<a class="navbar-brand hiddenMediumView" href="/" tabindex="16" >
|
||||
<a class="navbar-brand hiddenMediumView" th:href="@{/}" tabindex="16" >
|
||||
<img class="main-icon" src="favicon.svg" alt="icon" style="max-height: 1.6rem; width: auto;">
|
||||
<span class="icon-text" style="color: #ffffff;" th:text="${@appName}">Stirling PDF</span>
|
||||
</a>
|
||||
|
@ -308,7 +308,7 @@ See https://github.com/adobe-type-tools/cmap-resources
|
|||
<button id="editorHighlight" class="toolbarButton" hidden="true" disabled="disabled" title="Highlight" role="radio" aria-checked="false" aria-controls="editorHighlightParamsToolbar" tabindex="31" data-l10n-id="pdfjs-editor-highlight-button">
|
||||
<span data-l10n-id="pdfjs-editor-highlight-button-label">Highlight</span>
|
||||
</button>
|
||||
<a id="backToHome" class="toolbarButton hiddenMediumView" title="Back to Main Page" role="radio" aria-checked="false" tabindex="32" href="/">
|
||||
<a id="backToHome" class="toolbarButton hiddenMediumView" title="Back to Main Page" role="radio" aria-checked="false" tabindex="32" th:href="@{/}">
|
||||
<span data-l10n-id="pdfjs-open-file-button-label">Back to Main Page</span>
|
||||
</a>
|
||||
<button id="openFile" class="toolbarButton hiddenMediumView" title="Open File" role="radio" aria-checked="false" tabindex="33" data-l10n-id="pdfjs-open-file-button">
|
||||
|
|
Loading…
Reference in a new issue