Enhance user privacy checks and improve error handling in user services
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good

This commit is contained in:
2026-01-16 17:15:25 +01:00
parent 8bace01238
commit f8c661ccb6
4 changed files with 115 additions and 62 deletions
@@ -33,6 +33,8 @@ public class UserController {
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Nutzerprofil erfolgreich abgerufen",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = MinimalUserDTO.class))),
@ApiResponse(responseCode = "403", description = "Nutzerprofil darf nicht aufgerufen werden",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "404", description = "Nutzerprofil nicht gefunden",
content = @Content(mediaType = "application/json"))
})
@@ -45,7 +47,7 @@ public class UserController {
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Nutzerprofil erfolgreich abgerufen",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = MinimalUserDTO.class))),
@ApiResponse(responseCode = "404", description = "Nutzerprofil nicht gefunden",
@ApiResponse(responseCode = "404", description = "Der Nutzer existiert nicht",
content = @Content(mediaType = "application/json"))
})
@GetMapping("/profile")
@@ -55,10 +57,9 @@ public class UserController {
@Operation(summary = "Nutzer löscht sein eigenes Profil", description = "Ein Nutzer kann sein eigenes Profil löschen. Dies entfernt alle seine Daten aus dem System.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Nutzerprofil erfolgreich gelöscht",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "404", description = "Nutzerprofil nicht gefunden",
content = @Content(mediaType = "application/json"))
@ApiResponse(responseCode = "200", description = "Nutzerprofil erfolgreich gelöscht"),
@ApiResponse(responseCode = "403", description = "Keine Berechtigung, fremdes Profil zu löschen"),
@ApiResponse(responseCode = "404", description = "Der Nutzer existiert nicht")
})
@DeleteMapping("/delete/{id}")
public ResponseEntity<Object> deleteUser(@PathVariable @NotNull Long id) {
@@ -71,6 +72,16 @@ public class UserController {
}
@Operation(summary = "Update a users private name.", description = "A user can change it's own private name that is shown to friends.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Passwort erfolgreich geändert",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "400", description = "Ungültige Eingabedaten",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "403", description = "Nur autorisierte Personen dürfen das Passwort ändern",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "404", description = "Der Nutzer existiert nicht",
content = @Content(mediaType = "application/json"))
})
@PutMapping("/setPrivateName/{id}")
public ResponseEntity<Void> setPrivateName(@PathVariable @NotNull Long id,
@RequestParam @NotBlank String newPrivateName) {
@@ -83,6 +94,10 @@ public class UserController {
@ApiResponse(responseCode = "200", description = "Passwort erfolgreich geändert",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "400", description = "Ungültige Eingabedaten",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "403", description = "Nur autorisierte Personen dürfen das Passwort ändern",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "404", description = "Der Nutzer existiert nicht",
content = @Content(mediaType = "application/json"))
})
@PutMapping("/setPassword/{id}")
@@ -96,6 +111,12 @@ public class UserController {
@ApiResponse(responseCode = "200", description = "E-Mail-Adresse erfolgreich geändert",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "400", description = "Ungültige Eingabedaten",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "403", description = "Nur autorisierte Personen dürfen die Email ändern",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "404", description = "Der Nutzer existiert nicht",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "409", description = "Die Email wurde bereits vergeben",
content = @Content(mediaType = "application/json"))
})
@PutMapping("/setEmail/{id}")
@@ -109,6 +130,10 @@ public class UserController {
@ApiResponse(responseCode = "200", description = "Sichtbarkeits- und Datenschutzeinstellungen erfolgreich geändert",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "400", description = "Ungültige Eingabedaten",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "403", description = "Ungültige Eingabedaten",
content = @Content(mediaType = "application/json")),
@ApiResponse(responseCode = "409", description = "Ungültige Eingabedaten",
content = @Content(mediaType = "application/json"))
})
@PutMapping("/setVisibilityPrivacy")