Skip to content

Return Id On Api Key Creation #487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Return id on creation of api key
  • Loading branch information
aq-ikhwa-tech committed Nov 10, 2023
commit cc9fb9bde4a12782b59bcf5b262bddbbe9fe78a3
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