aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java')
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java11
1 files changed, 3 insertions, 8 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java
index 02526af..21cd1b3 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/UserController.java
@@ -5,6 +5,7 @@ import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
+import com.ufund.api.ufundapi.DuplicateKeyException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@@ -20,12 +21,6 @@ public class UserController {
private final UserService userService;
private final AuthService authService;
- /**
- * Creates a UserController
- *
- * @param userService
- * @param authService
- */
public UserController(UserService userService, AuthService authService) {
this.userService = userService;
this.authService = authService;
@@ -49,7 +44,8 @@ public class UserController {
} else {
return new ResponseEntity<>(HttpStatus.CONFLICT);
}
-
+ } catch (DuplicateKeyException ex) {
+ return new ResponseEntity<>(HttpStatus.CONFLICT);
} catch (IOException ex) {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
@@ -93,7 +89,6 @@ public class UserController {
*/
@PutMapping("/{username}")
public ResponseEntity<User> updateUser(@RequestBody User user, @PathVariable String username, @RequestHeader("jelly-api-key") String key) {
-
try {
authService.authenticate(username, key);
user = userService.updateUser(user, username);