Skip to content

Commit

Permalink
Merge pull request #487 from lowcoder-org/return-id-on-api-key-creation
Browse files Browse the repository at this point in the history
Return Id On Api Key Creation
  • Loading branch information
FalkWolsky authored Nov 10, 2023
2 parents d380b63 + 671680b commit 05c0cc8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.lowcoder.domain.user.model;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

Expand All @@ -8,6 +9,7 @@

@Getter
@Setter
@Builder
public class APIKey {

private String id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public Mono<APIKeyVO> createAPIKey(APIKeyRequest apiKeyRequest) {
String token = jwtUtils.createToken(user);
APIKey apiKey = new APIKey(apiKeyRequest.getId(), apiKeyRequest.getName(), apiKeyRequest.getDescription(), token);
addAPIKey(user, apiKey);
return Pair.of(token, user);
return Pair.of(APIKey.builder().id(apiKey.getId()).token(token).build(), user);
})
.flatMap(pair -> userService.update(pair.getRight().getId(), pair.getRight()).thenReturn(pair.getKey()))
.map(APIKeyVO::from);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

import lombok.Builder;
import lombok.Getter;
import org.lowcoder.domain.user.model.APIKey;

@Builder
@Getter
public class APIKeyVO {

private final String id;
private final String token;

public static APIKeyVO from(String token) {
public static APIKeyVO from(APIKey apiKey) {
return APIKeyVO.builder()
.token(token)
.id(apiKey.getId())
.token(apiKey.getToken())
.build();
}

Expand Down

0 comments on commit 05c0cc8

Please sign in to comment.