Try custom putput
This commit is contained in:
parent
f17bb85837
commit
e3bf0b6421
1 changed files with 6 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue