Skip to content

Commit

Permalink
Use Descriptor.bindJSON to support complex describable fields in cust…
Browse files Browse the repository at this point in the history
…om credentials
  • Loading branch information
dwnusbaum committed Oct 3, 2023
1 parent 79a4753 commit 0a31917
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ public void doAddCredentials(StaplerRequest req, StaplerResponse rsp) throws IOE
.generateResponse(req, rsp, null);
}
store.checkPermission(CredentialsStoreAction.CREATE);
Credentials credentials = req.bindJSON(Credentials.class, data.getJSONObject("credentials"));
Credentials credentials = Descriptor.bindJSON(req, Credentials.class, data.getJSONObject("credentials"));
store.addCredentials(wrapper.getDomain(), credentials);
FormApply.applyResponse("window.credentials.refreshAll();").generateResponse(req, rsp, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ public HttpResponse doCreateCredentials(StaplerRequest req) throws ServletExcept
}
} else {
JSONObject data = req.getSubmittedForm();
Credentials credentials = req.bindJSON(Credentials.class, data.getJSONObject("credentials"));
Credentials credentials = Descriptor.bindJSON(req, Credentials.class, data.getJSONObject("credentials"));
getStore().addCredentials(domain, credentials);
return HttpResponses.redirectTo("../../domain/" + getUrlName());
}
Expand Down Expand Up @@ -1394,7 +1394,7 @@ public HttpResponse doDoMove(StaplerRequest req, @QueryParameter String destinat
public HttpResponse doUpdateSubmit(StaplerRequest req) throws ServletException, IOException {
getStore().checkPermission(UPDATE);
JSONObject data = req.getSubmittedForm();
Credentials credentials = req.bindJSON(Credentials.class, data);
Credentials credentials = Descriptor.bindJSON(req, Credentials.class, data);
if (!getStore().updateCredentials(this.domain.domain, this.credentials, credentials)) {
return HttpResponses.redirectTo("concurrentModification");
}
Expand Down

0 comments on commit 0a31917

Please sign in to comment.