Skip to content

Commit 375c6c5

Browse files
authored
Merge pull request #3 from CodeSpoof/json
use json lib for encoding
2 parents 3fbce8a + c544e42 commit 375c6c5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/src/main/java/io/codespoof/univpassm/PasswordTask.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,16 @@ protected String createConnection(String path, String body, String cookies) thro
8383
}
8484

8585
protected String doAuth(String username, String password) throws JSONException, IOException {
86-
return createConnection("/univention/auth", "{\"options\":{\"username\":\"" + username + "\",\"password\":\"" + password + "\"}}", null);
86+
JSONObject json = new JSONObject("{\"options\":{\"username\":\"\",\"password\":\"\"}}");
87+
json.getJSONObject("options").put("username", username);
88+
json.getJSONObject("options").put("password", password);
89+
return createConnection("/univention/auth", json.toString(), null);
8790
}
8891

8992
protected boolean doChange(String oldPassword, String newPassword, String cookies) throws JSONException, IOException {
90-
return createConnection("/univention/set/password", "{\"options\":{\"password\":{\"password\":\"" + oldPassword + "\",\"new_password\":\"" + newPassword + "\"}}}", cookies) != null;
93+
JSONObject json = new JSONObject("{\"options\":{\"password\":{\"password\":\"\",\"new_password\":\"\"}}}");
94+
json.getJSONObject("options").getJSONObject("password").put("password", oldPassword);
95+
json.getJSONObject("options").getJSONObject("password").put("new_password", newPassword);
96+
return createConnection("/univention/set/password", json.toString(), cookies) != null;
9197
}
9298
}

0 commit comments

Comments
 (0)