Skip to content

Commit 8f4085b

Browse files
vinokurigclaude
andauthored
Add endpoint to retrieve current user name (#1018)
Introduces a new GET /name endpoint in UserService that returns the current user's name from the environment context. Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent f031921 commit 8f4085b

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

  • wsmaster/che-core-api-user/src/main/java/org/eclipse/che/api/user/server

wsmaster/che-core-api-user/src/main/java/org/eclipse/che/api/user/server/UserService.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012-2025 Red Hat, Inc.
2+
* Copyright (c) 2012-2026 Red Hat, Inc.
33
* This program and the accompanying materials are made
44
* available under the terms of the Eclipse Public License 2.0
55
* which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -51,6 +51,20 @@ public String getId() {
5151
return userId();
5252
}
5353

54+
@GET
55+
@Path("/name")
56+
@Produces(TEXT_PLAIN)
57+
@Operation(
58+
summary = "Get current user name",
59+
responses = {
60+
@ApiResponse(
61+
responseCode = "200",
62+
description = "The response contains current user's name"),
63+
})
64+
public String getUser() {
65+
return EnvironmentContext.getCurrent().getSubject().getUserName();
66+
}
67+
5468
private static String userId() {
5569
return EnvironmentContext.getCurrent().getSubject().getUserId();
5670
}

0 commit comments

Comments
 (0)