|
|
@ -2,20 +2,21 @@ package org.ros.chatto.controller; |
|
|
|
|
|
|
|
import java.security.Principal; |
|
|
|
import java.time.Instant; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import javax.validation.Valid; |
|
|
|
|
|
|
|
import com.spencerwi.either.Result; |
|
|
|
|
|
|
|
import org.ros.chatto.dto.AdminUserDTO; |
|
|
|
import org.ros.chatto.dto.ChatMessageDTO; |
|
|
|
import org.ros.chatto.dto.ReencryptionDTO; |
|
|
|
import org.ros.chatto.service.AdminService; |
|
|
|
import org.ros.chatto.service.ChatService; |
|
|
|
import org.ros.chatto.service.UserService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.PathVariable; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
@ -70,4 +71,17 @@ public class AdminRESTController { |
|
|
|
public List<AdminUserDTO> getAllOtherUsers(Principal principal) { |
|
|
|
return adminService.getOtherUsers(principal.getName()); |
|
|
|
} |
|
|
|
|
|
|
|
@DeleteMapping("/delete/users/{userName}") |
|
|
|
public ResponseEntity<?> deleteUser(@PathVariable String userName) { |
|
|
|
Result<Void> res = adminService.deleteUser(userName); |
|
|
|
if (res.isOk()) { |
|
|
|
return ResponseEntity.ok() |
|
|
|
.body("Deleted User with name - " + userName); |
|
|
|
} else { |
|
|
|
return ResponseEntity.badRequest().body( |
|
|
|
"An error occured while trying to delete user with name - " |
|
|
|
+ userName); |
|
|
|
} |
|
|
|
} |
|
|
|
} |