Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2025 Red Hat, Inc.
* Copyright (c) 2012-2026 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -11,7 +11,9 @@
*/
package org.eclipse.che.api.user.server;

import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON;
import static jakarta.ws.rs.core.MediaType.TEXT_PLAIN;
import static org.eclipse.che.dto.server.DtoFactory.newDto;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand All @@ -21,6 +23,7 @@
import jakarta.ws.rs.Produces;
import javax.inject.Inject;
import org.eclipse.che.api.core.rest.Service;
import org.eclipse.che.api.user.shared.dto.UserDto;
import org.eclipse.che.commons.env.EnvironmentContext;

/**
Expand Down Expand Up @@ -51,6 +54,20 @@ public String getId() {
return userId();
}

@GET
@Produces(APPLICATION_JSON)
@Operation(
summary = "Get current user",
responses = {
@ApiResponse(
responseCode = "200",
description = "The response contains current user's object with name and email fields"),
})
public UserDto getUser() {
String userName = EnvironmentContext.getCurrent().getSubject().getUserName();
return newDto(UserDto.class).withName(userName).withEmail(userName + "@che");
}

private static String userId() {
return EnvironmentContext.getCurrent().getSubject().getUserId();
}
Expand Down
Loading