8000 fixed #28 · githubcs/baasbox@e0f9ced · GitHub
[go: up one dir, main page]

Skip to content

Commit e0f9ced

Browse files
committed
fixed baasbox#28
1 parent f06ca3c commit e0f9ced

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

app/com/baasbox/controllers/Document.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ public static Result createDocument(String collection){
183183
JsonNode bodyJson= body.asJson();
184184
Logger.trace("creating document in collection: " + collection);
185185
Logger.trace("bodyJson: " + bodyJson);
186+
if (bodyJson==null) return badRequest("The body payload cannot be empty. Hint: put in the request header Content-Type: application/json");
186187
ODocument document;
187188
try{
188189
document=DocumentService.create(collection, bodyJson);
@@ -205,6 +206,7 @@ public static Result updateDocument(String collectionName, String rid){
205206
JsonNode bodyJson= body.asJson();
206207
Logger.trace("updateDocument collectionName: " + collectionName);
207208
Logger.trace("updateDocument rid: " + rid);
209+
if (bodyJson==null) return badRequest("The body payload cannot be empty. Hint: put in the request header Content-Type: application/json");
208210
ODocument document=null;
209211
try{
210212
document=com.baasbox.service.storage.DocumentService.update(collectionName, rid, bodyJson);

app/com/baasbox/controllers/User.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ public static Result signUp(){
7777
Http.RequestBody body = request().body();
7878

7979
JsonNode bodyJson= body.asJson();
80-
Logger.debug("signUp bodyJson: " + bodyJson);
81-
80+
Logger.trace("signUp bodyJson: " + bodyJson);
81+
if (bodyJson==null) return badRequest("The body payload cannot be empty. Hint: put in the request header Content-Type: application/json");
8282
//check and validate input
8383
if (!bodyJson.has("username"))
8484
return badRequest("The 'username' field is missing");
@@ -113,7 +113,8 @@ public static Result updateProfile(){
113113
Http.RequestBody body = request().body();
114114

115115
JsonNode bodyJson= body.asJson();
116-
Logger.debug("updateProfile bodyJson: " + bodyJson);
116+
Logger.trace("updateProfile bodyJson: " + bodyJson);
117+
if (bodyJson==null) return badRequest("The body payload cannot be empty. Hint: put in the request header Content-Type: application/json");
117118

118119
//extract the profile fields
119120
JsonNode nonAppUserAttributes = bodyJson.get(UserDao.ATTRIBUTES_VISIBLE_BY_ANONYMOUS_USER);
@@ -162,7 +163,8 @@ public static Result changePassword(){
162163
Http.RequestBody body = request().body();
163164

164165
JsonNode bodyJson= body.asJson();
165-
Logger.debug("changePassword bodyJson: " + bodyJson);
166+
Logger.trace("changePassword bodyJson: " + bodyJson);
167+
if (bodyJson==null) return badRequest("The body payload cannot be empty. Hint: put in the request header Content-Type: application/json");
166168

167169
//check and validate input
168170
if (!bodyJson.has("old"))

0 commit comments

Comments
 (0)
0