Commit bb96e523 authored by Matija Obreza's avatar Matija Obreza

Fixed bug in registration of new OAuth clients

parent d2ca50a6
......@@ -135,15 +135,13 @@ public class OAuthManagementController extends BaseController {
}
@PreAuthorize("hasAnyRole('VETTEDUSER','ADMINISTRATOR')")
@RequestMapping(value = "/save-client", method = RequestMethod.POST, params = "newClient=new")
public String createClientEntry(Model model, @RequestParam("title") String title, @RequestParam("description") String description,
@RequestParam(value = "redirectUris", required = false) String redirectUris, @RequestParam(name = "accessTokenValidity", required = false) Integer accessTokenValiditySeconds,
@RequestParam(name = "refreshTokenValidity", required = false) Integer refreshTokenValiditySeconds, @RequestParam(name = "clientType", required = false) String clientType) {
@RequestMapping(value = "/save-client", method = RequestMethod.POST, params = "action-save")
public @ResponseBody OAuthClient createClientEntry(Model model, @RequestBody @JsonView(JsonViews.Protected.class) OAuthClient client) {
OAuthClient oauthClient = clientDetailsService.addClient(title, description, redirectUris, accessTokenValiditySeconds, refreshTokenValiditySeconds);
OAuthClient oauthClient = clientDetailsService.addClient(client);
LOG.info("Created OAuth client with clientId={}", oauthClient.getClientId());
return "redirect:" + CONTROLLER_PATH + "/";
return oauthClient;
}
@PreAuthorize("hasAnyRole('VETTEDUSER','ADMINISTRATOR')")
......
......@@ -8,14 +8,16 @@
</head>
<body>
<form role="form" class="form-horizontal validate" action="<c:url value='/admin/oauth-clients/save-client' />" method="post">
<c:if test="${clientDetails.id gt 0}">
<input type="hidden" name="id" value="${clientDetails.id}"/>
</c:if>
<input type="hidden" name="version" value="${clientDetails.version}"/>
<input type="hidden" name="clientId" value="${clientDetails.clientId}"/>
<c:if test="${clientDetails == null}">
<input type="hidden" name="newClient" value="new"/>
</c:if>
<c:choose>
<c:when test="${clientDetails.id gt 0}">
<input type="hidden" name="id" value="${clientDetails.id}"/>
<input type="hidden" name="version" value="${clientDetails.version}"/>
<input type="hidden" name="clientId" value="${clientDetails.clientId}"/>
</c:when>
<%-- <c:otherwise>
<input type="hidden" name="version" value="0"/>
</c:otherwise> --%>
</c:choose>
<div class="form-group">
<label for="clientId" class="col-lg-3 col-md-4 control-label"><spring:message code="oauth-client.id"/></label>
<div class="col-lg-9 col-md-8">
......@@ -175,7 +177,7 @@
delete data.redirect;
console.log(data);
$.ajax({
url: form.action + "?action-save=1&id=" + data.id + "&version=" + data.version,
url: form.action + "?action-save=1" + (data.id === undefined ? "" : "&id=" + data.id + "&version=" + data.version),
type: 'POST',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
......@@ -184,7 +186,7 @@
: JSON.stringify(data)),
success: function (response) {
// console.log('saved', response);
window.location = window.location;
window.location.pathname = '/admin/oauth-clients/' + response.clientId + '/';
}
});
return false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment