fix: show descriptive error when creating local user with OIDC enabled

Return a JSON error body from UserAdminController instead of an empty 400,
and extract API error messages in adminFetch so toasts display the reason.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-09 18:19:10 +02:00
parent 2771dffb78
commit be585934b9
3 changed files with 17 additions and 5 deletions

View File

@@ -87,10 +87,11 @@ public class UserAdminController {
@Operation(summary = "Create a local user")
@ApiResponse(responseCode = "200", description = "User created")
@ApiResponse(responseCode = "400", description = "Disabled in OIDC mode")
public ResponseEntity<UserDetail> createUser(@RequestBody CreateUserRequest request,
public ResponseEntity<?> createUser(@RequestBody CreateUserRequest request,
HttpServletRequest httpRequest) {
if (oidcEnabled) {
return ResponseEntity.badRequest().build();
return ResponseEntity.badRequest()
.body(Map.of("error", "Local user creation is disabled when OIDC is enabled. Users are provisioned automatically via SSO."));
}
String userId = "user:" + request.username();
UserInfo user = new UserInfo(userId, "local",