Try custom putput

This commit is contained in:
Ryan Voots 2024-01-25 12:46:50 -05:00
parent f17bb85837
commit e3bf0b6421

View file

@ -19,9 +19,11 @@ public class ApiKeyResource {
@GET
@Produces("application/json")
public Response checkApiKey(@QueryParam("apiKey") String apiKey) {
return session.users().searchForUserByUserAttributeStream(session.getContext().getRealm(), "api-key", apiKey)
.findFirst().isPresent() ? Response.ok().type(MediaType.APPLICATION_JSON).build():
Response.status(401).type(MediaType.APPLICATION_JSON).build();
public List<UserRepresentation> checkApiKey(@QueryParam("apiKey") String apiKey) {
var user = session.users().searchForUserByUserAttributeStream(session.getContext().getRealm(), "api-key", apiKey)
.stream()
.map(userModel -> ModelToRepresentation.toRepresentation(session, session.getContext().getRealm(), userModel))
.collect(toList());
return user;
}
}