Bugfix: user can change email and password accordingly
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package SuMoC.backend.user.controller;
|
||||
|
||||
import SuMoC.backend.security.dtos.LoginResponseDTO;
|
||||
import SuMoC.backend.user.dtos.MaximalUserDTO;
|
||||
import SuMoC.backend.user.dtos.MinimalUserDTO;
|
||||
import SuMoC.backend.user.enums.VisibilityPrivacy;
|
||||
import SuMoC.backend.user.service.UserService;
|
||||
@@ -39,6 +41,18 @@ public class UserController {
|
||||
return new ResponseEntity<>(this.userService.getUser(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Operation(summary = "Nutzer fragt sein eigenes Profil an", description = "Ein Nutzer kann sein eigenes Profil anfragen, um dessen Informationen einzusehen.")
|
||||
@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",
|
||||
content = @Content(mediaType = "application/json"))
|
||||
})
|
||||
@GetMapping("/profile")
|
||||
public ResponseEntity<MaximalUserDTO> getUser() {
|
||||
return new ResponseEntity<>(this.userService.getSelf(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@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",
|
||||
@@ -57,10 +71,10 @@ 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.")
|
||||
@PutMapping("/changePrivateName/{id}")
|
||||
public ResponseEntity<Void> changePrivateName(@PathVariable @NotNull Long id,
|
||||
@PutMapping("/setPrivateName/{id}")
|
||||
public ResponseEntity<Void> setPrivateName(@PathVariable @NotNull Long id,
|
||||
@RequestParam @NotBlank String newPrivateName) {
|
||||
this.userService.changePrivateName(id, newPrivateName);
|
||||
this.userService.setPrivateName(id, newPrivateName);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@@ -71,11 +85,10 @@ public class UserController {
|
||||
@ApiResponse(responseCode = "400", description = "Ungültige Eingabedaten",
|
||||
content = @Content(mediaType = "application/json"))
|
||||
})
|
||||
@PutMapping("/changePassword/{id}")
|
||||
public ResponseEntity<Object> changePassword(@PathVariable @NotNull Long id,
|
||||
@RequestParam @NotBlank String newPassword) {
|
||||
this.userService.changePassword(id, newPassword);
|
||||
return ResponseEntity.ok().build();
|
||||
@PutMapping("/setPassword/{id}")
|
||||
public ResponseEntity<LoginResponseDTO> setPassword(@PathVariable @NotNull Long id,
|
||||
@RequestParam @NotBlank String newPassword) {
|
||||
return new ResponseEntity<>(this.userService.setPassword(id, newPassword), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Operation(summary = "Nutzer ändert seine E-Mail-Adresse", description = "Ein Nutzer kann seine E-Mail-Adresse ändern, um sicherzustellen, dass seine Kontaktdaten aktuell sind.")
|
||||
@@ -85,11 +98,10 @@ public class UserController {
|
||||
@ApiResponse(responseCode = "400", description = "Ungültige Eingabedaten",
|
||||
content = @Content(mediaType = "application/json"))
|
||||
})
|
||||
@PutMapping("/changeEmail/{id}")
|
||||
public ResponseEntity<Object> changeEmail(@PathVariable @NotNull Long id,
|
||||
@PutMapping("/setEmail/{id}")
|
||||
public ResponseEntity<Object> setEmail(@PathVariable @NotNull Long id,
|
||||
@RequestParam @NotBlank String newEmail) {
|
||||
this.userService.changeEmail(id, newEmail);
|
||||
return ResponseEntity.ok().build();
|
||||
return new ResponseEntity<>(this.userService.setEmail(id, newEmail), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Operation(summary = "Nutzer ändert seine Sichtbarkeits- und Datenschutzeinstellungen", description = "Ein Nutzer kann seine Sichtbarkeits- und Datenschutzeinstellungen ändern, um zu steuern, wer seine Informationen sehen kann.")
|
||||
@@ -99,9 +111,9 @@ public class UserController {
|
||||
@ApiResponse(responseCode = "400", description = "Ungültige Eingabedaten",
|
||||
content = @Content(mediaType = "application/json"))
|
||||
})
|
||||
@PutMapping("/changeVisibilityPrivacy")
|
||||
public ResponseEntity<Void> changeVisibilityPrivacy(@RequestParam @NotNull VisibilityPrivacy visibilityPrivacy) {
|
||||
this.userService.changeVisibilityPrivacy(visibilityPrivacy);
|
||||
@PutMapping("/setVisibilityPrivacy")
|
||||
public ResponseEntity<Void> setVisibilityPrivacy(@RequestParam @NotNull VisibilityPrivacy visibilityPrivacy) {
|
||||
this.userService.setVisibilityPrivacy(visibilityPrivacy);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user