Skip to content

Commit

Permalink
Merge pull request #3192 from keeps/alindo-dev-create-user
Browse files Browse the repository at this point in the history
edited createUser
  • Loading branch information
hmiguim authored May 23, 2024
2 parents 2d2e5d1 + b89a2ee commit 8b9e2ad
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ protected ResponseEntity<Object> handleRestException(RuntimeException ex, WebReq
String details = "";
HttpStatus httpStatus = HttpStatus.INTERNAL_SERVER_ERROR;
UUID errorID = UUID.randomUUID();
if (ex.getCause() instanceof AuthorizationDeniedException || ex.getCause() instanceof AuthenticationDeniedException) {
if (ex.getCause() instanceof AuthorizationDeniedException) {
message = "Forbidden";
details = ex.getCause().getMessage();
httpStatus = HttpStatus.FORBIDDEN;
} else if (ex.getCause() instanceof AuthenticationDeniedException) {
message = "Unauthorized access";
details = ex.getCause().getMessage();
httpStatus = HttpStatus.UNAUTHORIZED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public void setUser(User user) {


Services services = new Services("Get User extra", "get");
services.membersResource(s -> s.getUserExtra(user.getName())).whenComplete((extra, error) -> {
services.membersResource(s -> s.getDefaultUserExtra()).whenComplete((extra, error) -> {
if (extra != null) {
CreateUserPanel.this.userExtra = extra;
createForm(userExtra);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public void setUser(User user) {
this.setPermissions(user.getDirectRoles(), user.getAllRoles());

Services services = new Services("Get User extra", "get");
services.membersResource(s -> s.getUserExtra(user.getName())).whenComplete((extra, error) -> {
services.membersResource(s -> s.getDefaultUserExtra()).whenComplete((extra, error) -> {
if (extra != null) {
UserDataPanel.this.userExtra = extra;
createForm(userExtra);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ Void changeActive(
Void deleteMultipleMembers(
@Parameter(name = "selectedItems", required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)) SelectedItems<RODAMember> members);

@RequestMapping(path = "/users/create", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(path = "/users", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
@Operation(summary = "Create user", requestBody = @RequestBody(required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = User.class))), description = "Creates a new user", responses = {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = "409", description = "Already exists", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))})
@ApiResponse(responseCode = "201", description = "Created", content = @Content(schema = @Schema(implementation = User.class))),
@ApiResponse(responseCode = "409", description = "Conflict", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class))),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(implementation = ErrorResponseMessage.class)))})
User createUser(
@Parameter(name = "user", required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)) CreateUserRequest userOperations,
@Parameter(description = "localeString") @RequestParam(name = "locale") String localeString);
@Parameter(description = "The language to be used for internationalization") @RequestParam(name = "lang", defaultValue = "en", required = false) String localeString);

@RequestMapping(path = "/users/register", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
Expand Down

0 comments on commit 8b9e2ad

Please sign in to comment.