mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-12 17:52:13 +02:00
Merge branch 'main' into scan-filter
This commit is contained in:
commit
e8b0c2e1cc
@ -3,7 +3,6 @@ package stirling.software.SPDF.controller.api;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -168,13 +167,23 @@ public class UserController {
|
|||||||
|
|
||||||
@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")
|
@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")
|
||||||
@PostMapping("/updateUserSettings")
|
@PostMapping("/updateUserSettings")
|
||||||
public String updateUserSettings(HttpServletRequest request, Principal principal)
|
/**
|
||||||
|
* Updates the user settings based on the provided JSON payload.
|
||||||
|
*
|
||||||
|
* @param updates A map containing the settings to update. The expected structure is:
|
||||||
|
* <ul>
|
||||||
|
* <li><b>emailNotifications</b> (optional): "true" or "false" - Enable or disable email notifications.</li>
|
||||||
|
* <li><b>theme</b> (optional): "light" or "dark" - Set the user's preferred theme.</li>
|
||||||
|
* <li><b>language</b> (optional): A string representing the preferred language (e.g., "en", "fr").</li>
|
||||||
|
* </ul>
|
||||||
|
* Keys not listed above will be ignored.
|
||||||
|
* @param principal The currently authenticated user.
|
||||||
|
* @return A redirect string to the account page after updating the settings.
|
||||||
|
* @throws SQLException If a database error occurs.
|
||||||
|
* @throws UnsupportedProviderException If the operation is not supported for the user's provider.
|
||||||
|
*/
|
||||||
|
public String updateUserSettings(@RequestBody Map<String, String> updates, Principal principal)
|
||||||
throws SQLException, UnsupportedProviderException {
|
throws SQLException, UnsupportedProviderException {
|
||||||
Map<String, String[]> paramMap = request.getParameterMap();
|
|
||||||
Map<String, String> updates = new HashMap<>();
|
|
||||||
for (Map.Entry<String, String[]> entry : paramMap.entrySet()) {
|
|
||||||
updates.put(entry.getKey(), entry.getValue()[0]);
|
|
||||||
}
|
|
||||||
log.debug("Processed updates: {}", updates);
|
log.debug("Processed updates: {}", updates);
|
||||||
// Assuming you have a method in userService to update the settings for a user
|
// Assuming you have a method in userService to update the settings for a user
|
||||||
userService.updateUserSettings(principal.getName(), updates);
|
userService.updateUserSettings(principal.getName(), updates);
|
||||||
|
Loading…
Reference in New Issue
Block a user