This commit is contained in:
Anthony Stirling 2024-06-06 21:59:13 +01:00
parent a3bf7baf35
commit 03150c6462
4 changed files with 83 additions and 79 deletions

View file

@ -7,7 +7,6 @@ import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import org.springframework.context.ApplicationContextInitializer;
@ -55,7 +54,8 @@ public class ConfigInitializer
//
// List<String> templateLines = Files.readAllLines(templatePath);
// List<String> userLines =
// Files.exists(userPath) ? Files.readAllLines(userPath) : new ArrayList<>();
// Files.exists(userPath) ? Files.readAllLines(userPath) : new
// ArrayList<>();
//
// List<String> resultLines = new ArrayList<>();
// int position = 0;

View file

@ -8,7 +8,6 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.thymeleaf.IEngineConfiguration;
import org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver;
import org.thymeleaf.templateresource.ClassLoaderTemplateResource;
import org.thymeleaf.templateresource.FileTemplateResource;
import org.thymeleaf.templateresource.ITemplateResource;
@ -43,7 +42,10 @@ public class FileFallbackTemplateResolver extends AbstractConfigurableTemplateRe
}
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("templates/" + resourceName);
InputStream inputStream =
Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream("templates/" + resourceName);
if (inputStream != null) {
return new InputStreamTemplateResource(inputStream, "UTF-8");
}

View file

@ -231,7 +231,8 @@ public class UserController {
}
userService.saveUser(username, password, role, forceChange);
return new RedirectView("/addUsers",true); // 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')")
@ -270,7 +271,8 @@ public class UserController {
User user = userOpt.get();
userService.changeRole(user, role);
return new RedirectView("/addUsers",true); // 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')")