Skip to content

Commit

Permalink
Merge pull request #488 from dwnusbaum/descriptor-newinstance-compati…
Browse files Browse the repository at this point in the history
…bility

Use `Descriptor.bindJSON` to support complex describable fields in custom credentials
  • Loading branch information
jtnord authored Oct 3, 2023
2 parents 79a4753 + 0a31917 commit ff276f7
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 ff276f7

Please sign in to comment.