Skip to content
Snippets Groups Projects
Commit 83834c13 authored by Henrik Teksle Sandok's avatar Henrik Teksle Sandok
Browse files

Merge branch 'feat/delete-account-endpoint' into 'master'

feat: delete account endpoint

See merge request !92
parents e2fd3f9f b4822705
No related branches found
No related tags found
1 merge request!92feat: delete account endpoint
Pipeline #284955 passed
......@@ -152,6 +152,17 @@ public class UserController {
return ResponseEntity.ok(userDTO);
}
@Operation(summary = "Delete the authenticated user", description = "Delete the authenticated user")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully deleted user")
})
@DeleteMapping(value = "/me", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Void> deleteUser(@AuthenticationPrincipal AuthIdentity identity) {
userService.delete(identity.getId());
log.info("[UserController:deleteUser] user: {}", identity.getId());
return ResponseEntity.ok().build();
}
@Operation(summary = "Update a password", description = "Update the password of the authenticated user")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully updated password")
......
......@@ -55,6 +55,15 @@ public interface UserService {
*/
User update(User user);
/**
* Deletes a user from the system based on the specified user ID.
* This method permanently removes the user's record from the database. It should be used with caution,
* as this operation is irreversible and results in the loss of all data associated with the user's account.
*
* @param userId The unique identifier of the user to be deleted.
*/
void delete(long userId);
/**
* Updates the password of a user.
*
......
......@@ -227,6 +227,18 @@ public class UserServiceImpl implements UserService {
}
}
/**
* Deletes a user from the system based on the specified user ID.
* This method permanently removes the user's record from the database. It should be used with caution,
* as this operation is irreversible and results in the loss of all data associated with the user's account.
*
* @param userId The unique identifier of the user to be deleted.
*/
@Override
public void delete(long userId) {
userRepository.deleteById(userId);
}
/**
* Updates the password of a user.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment