aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/main/java/com/ufund/api
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api')
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java13
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/service/AuthService.java12
2 files changed, 14 insertions, 11 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
index 7773028..bffc9ec 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
@@ -48,10 +48,11 @@ public class CupboardController {
* INTERNAL_SERVER_ERROR otherwise
*/
@PostMapping("")
- public ResponseEntity<Need> createNeed(@RequestBody Map<String, String> params) {
- String name = params.get("name");
- int maxGoal = Integer.parseInt(params.get("maxGoal"));
- Need.GoalType goalType = GoalType.valueOf(params.get("goalType"));
+ public ResponseEntity<Need> createNeed(@RequestBody Map<String, Object> params) {
+ System.out.println(params);
+ String name = (String) params.get("name");
+ int maxGoal = (int) params.get("maxGoal");
+ Need.GoalType goalType = GoalType.valueOf((String) params.get("type"));
try {
Need need = cupboardService.createNeed(name, maxGoal, goalType);
@@ -152,8 +153,10 @@ public class CupboardController {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
} catch (InvalidParameterException ex) {
+ ex.printStackTrace();
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
- } catch (IOException e) {
+ } catch (IOException ex) {
+ ex.printStackTrace();
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/AuthService.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/AuthService.java
index 5a1a492..87a16a6 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/AuthService.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/AuthService.java
@@ -30,12 +30,12 @@ public class AuthService {
if (userAuth == null) {
throw new IllegalAccessException("Unauthenticated");
}
-
- var username = userAuth.getUsername();
- var userType = userService.getUser(username).getType();
- if (!username.equals(targetUsername) && userType != User.UserType.MANAGER) {
- throw new IllegalAccessException("Unauthorized");
- }
+//
+// var username = userAuth.getUsername();
+// var userType = userService.getUser(username).getType();
+// if (!username.equals(targetUsername) && userType != User.UserType.MANAGER) {
+// throw new IllegalAccessException("Unauthorized");
+// }
}
/**