Skip to content

Commit 3143507

Browse files
jerry-goodmanQIQI03
authored andcommitted
1. fix:serialize missing password... 2. fix:throw exception when username does not exist 3. feat:template application
1 parent 2bb0a73 commit 3143507

File tree

15 files changed

+45
-57
lines changed

15 files changed

+45
-57
lines changed

server/openblocks-domain/src/main/java/com/openblocks/domain/template/repository/TemplateRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ public interface TemplateRepository extends ReactiveMongoRepository<Template, St
2020

2121
Flux<Template> findByApplicationIdIn(Collection<String> applicationId);
2222

23-
Flux<Template> findByApplicationId(String applicationId);
23+
Mono<Template> findByApplicationId(String applicationId);
2424
}

server/openblocks-domain/src/main/java/com/openblocks/domain/template/service/TemplateService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public Flux<Template> getByApplicationIds(Collection<String> applicationIds) {
2727
return templateRepository.findByApplicationIdIn(applicationIds);
2828
}
2929

30-
public Flux<Template> getByApplicationId(String applicationId) {
30+
public Mono<Template> getByApplicationId(String applicationId) {
3131
return templateRepository.findByApplicationId(applicationId);
3232
}
3333
}

server/openblocks-domain/src/test/java/com/openblocks/domain/encryption/EncryptionServiceTest.java

Lines changed: 0 additions & 22 deletions
This file was deleted.

server/openblocks-domain/src/test/resources/application.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,21 @@ demo:
77
timeout: 8s
88
username: root
99

10+
spring:
11+
redis:
12+
url: redis://localhost:6369
13+
mongodb:
14+
embedded:
15+
version: 4.0.2
16+
main:
17+
allow-circular-references: true
18+
1019
common:
1120
domain:
1221
default-value: skipCheck
1322
encrypt:
14-
password: abcd
15-
salt: abcd
23+
password: openblocks.dev
24+
salt: openblocks.dev
1625
cloud: false
1726
security:
1827
cors-allowed-domains:
@@ -28,8 +37,4 @@ auth:
2837
mobile:
2938
enable: true
3039
email:
31-
enable: true
32-
33-
spring:
34-
redis:
35-
url: redis://localhost:6369
40+
enable: true

server/openblocks-plugins/googleSheetsPlugin/src/main/java/com/openblocks/plugin/googlesheets/model/GoogleSheetsReadDataRequest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ public void renderParams(Map<String, Object> paramMap) {
2929

3030
@Override
3131
public boolean hasInvalidData() {
32-
/*
33-
这里判断的时候先不判断range是否为空,因为按照retool的做法可能按照limit与offset
34-
*/
3532
return StringUtils.isAnyBlank(spreadsheetId, sheetName);
3633
}
3734
}

server/openblocks-plugins/googleSheetsPlugin/src/main/java/com/openblocks/plugin/googlesheets/model/GoogleSheetsUpdateDataRequest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
public class GoogleSheetsUpdateDataRequest implements GoogleSheetsActionRequest {
2222
private String spreadsheetId;
2323
private String sheetName;
24-
25-
//记住
2624
private int rowIndex;
2725
private String rowIndexString;
2826
private SheetChangeSet changeSet;

server/openblocks-plugins/googleSheetsPlugin/src/main/java/com/openblocks/plugin/googlesheets/queryhandler/GoogleSheetsActionHandlerFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class GoogleSheetsActionHandlerFactory {
2525
public static GoogleSheetsActionHandler getGoogleSheetsActionHandler(String actionType) {
2626
GoogleSheetsActionHandler googleSheetsActionHandler = HANDLER_MAP.get(actionType);
2727
if (googleSheetsActionHandler == null) {
28-
throw new PluginException(QUERY_ARGUMENT_ERROR, "非法谷歌表查询类型" + actionType);
28+
throw new PluginException(QUERY_ARGUMENT_ERROR, "GOOGLESHEETS_QUERY_PARAM_ERROR", actionType);
2929
}
3030
return googleSheetsActionHandler;
3131
}

server/openblocks-plugins/googleSheetsPlugin/src/main/java/com/openblocks/plugin/googlesheets/queryhandler/GoogleSheetsAppendDataHandler.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ public Mono<QueryExecutionResult> execute(Object o, GoogleSheetsQueryExecutionCo
5151
} catch (IOException e) {
5252
throw new RuntimeException(e);
5353
}
54-
/*
55-
获得第一行数据
56-
*/
5754
List<List<Object>> collect = null;
5855
List<Object> firstRow = values.get(0);
5956

@@ -75,9 +72,8 @@ public Mono<QueryExecutionResult> execute(Object o, GoogleSheetsQueryExecutionCo
7572
.map(entry -> tempMap.getOrDefault(entry, null) == null ? "" : tempMap.getOrDefault(entry, null))
7673
.collect(Collectors.toCollection(LinkedList::new));
7774
collect = List.of(row);
78-
// googleSheetsActionRequest.setRealData(newMap);
7975
} else {
80-
throw new PluginException(GOOGLESHEETS_EMPTY_QUERY_PARAM, "GOOGLESHEETS_QUERY_PARAM_ERROR");
76+
throw new PluginException(GOOGLESHEETS_EMPTY_QUERY_PARAM, "GOOGLESHEETS_QUERY_PARAM_EMPTY");
8177
}
8278
}
8379
ValueRange requestBody = new ValueRange();

server/openblocks-plugins/googleSheetsPlugin/src/main/java/com/openblocks/plugin/googlesheets/queryhandler/GoogleSheetsUpdateDataHandler.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public Mono<QueryExecutionResult> execute(Object o, GoogleSheetsQueryExecutionCo
6666
throw new RuntimeException(e);
6767
}
6868

69-
//同样的从changeSet拿出数据。
7069
List<List<Object>> collect;
7170
List<Object> headerList = values1.get(0);
7271
if (values2 == null) {
@@ -92,16 +91,12 @@ public Mono<QueryExecutionResult> execute(Object o, GoogleSheetsQueryExecutionCo
9291
}
9392
}
9493
if (Boolean.FALSE.equals(validValues)) {
95-
/*想在这里回传给前端一个错误信息
96-
* Could not map request back to existing data,目前看来是不能成功的
97-
* */
98-
throw new PluginException(GOOGLESHEETS_EMPTY_QUERY_PARAM, "GOOGLESHEETS_QUERY_PARAM_ERROR");
94+
throw new PluginException(GOOGLESHEETS_EMPTY_QUERY_PARAM, "GOOGLESHEETS_QUERY_PARAM_EMPTY");
9995
}
10096
final List<Object> tempObjects = new ArrayList<>(returnMap.values());
10197
collect = List.of(tempObjects);
10298
ValueRange requestBody = new ValueRange();
10399
requestBody.setMajorDimension("ROWS");
104-
// requestBody.setRange(range);
105100
requestBody.setValues(collect);
106101
Update request;
107102
UpdateValuesResponse response;

server/openblocks-plugins/smtpPlugin/src/main/java/com/openblocks/plugins/SmtpDatasourceConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
import javax.annotation.Nullable;
99

10-
import com.fasterxml.jackson.annotation.JsonProperty;
11-
import com.fasterxml.jackson.annotation.JsonProperty.Access;
10+
import com.fasterxml.jackson.annotation.JsonView;
11+
import com.openblocks.sdk.config.SerializeConfig.JsonViews;
1212
import com.openblocks.sdk.models.DatasourceConnectionConfig;
1313

1414
import lombok.Builder;
@@ -24,7 +24,7 @@ public class SmtpDatasourceConfig implements DatasourceConnectionConfig {
2424
@Nullable
2525
private final String username;
2626
@Nullable
27-
@JsonProperty(access = Access.WRITE_ONLY)
27+
@JsonView(JsonViews.Internal.class)
2828
private String password;
2929

3030
@Override

server/openblocks-sdk/src/main/java/com/openblocks/sdk/plugin/restapi/auth/BasicAuthConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import org.apache.commons.lang3.ObjectUtils;
88

99
import com.fasterxml.jackson.annotation.JsonCreator;
10-
import com.fasterxml.jackson.annotation.JsonProperty;
11-
import com.fasterxml.jackson.annotation.JsonProperty.Access;
10+
import com.fasterxml.jackson.annotation.JsonView;
11+
import com.openblocks.sdk.config.SerializeConfig.JsonViews;
1212

1313
import lombok.Getter;
1414

@@ -18,7 +18,7 @@
1818
@Getter
1919
public final class BasicAuthConfig extends AuthConfig {
2020
private final String username;
21-
@JsonProperty(access = Access.WRITE_ONLY)
21+
@JsonView(JsonViews.Internal.class)
2222
private String password;
2323

2424
@JsonCreator

server/openblocks-sdk/src/main/resources/locale_en.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ FAIL_TO_GET_OIDC_INFO=Failed to get OIDC information, error message: {0}.
4444
LOG_IN_SOURCE_NOT_SUPPORTED=Sorry, this log in channel is not supported.
4545
USER_LOGIN_ID_EXIST=Current email already used by another user.
4646
INVALID_PASSWORD=Sorry, passwords do not match, please retype.
47+
INVALID_EMAIL_OR_PASSWORD=Invalid email or password.
4748
ALREADY_BIND=Sorry, {0} has been bound by user {1}.
4849
NEED_BIND_THIRD_PARTY_CONNECTION=Sorry, it needs to bind the current workspace login channel.
4950
PAYLOAD_TOO_LARGE=Sorry,the maximum file size is {0} KB, your payload has reached the limit.
@@ -247,7 +248,7 @@ DUPLICATE_COLUMN=Duplicated columns found: {0}, use keyword ''as'' to rename dup
247248
INVALID_JSON_FROM_RESPONSE=Response data is not a valid JSON, please check your Content-Type header.
248249
REACH_REDIRECT_LIMIT=Reach maximum HTTP redirects: {0}.
249250
GOOGLESHEETS_QUERY_PARAM_EMPTY=Google Sheets query parameter is empty.
250-
GOOGLESHEETS_QUERY_PARAM_ERROR=Fail to map values to existing data.
251+
GOOGLESHEETS_QUERY_PARAM_ERROR=Google Sheets Query parameter is invalid: {0}.
251252
GOOGLESHEETS_REQUEST_ERROR=Google Sheets request failed.
252253
GOOGLESHEETS_DATASOURCE_CONFIG_ERROR=Fail to parse Google Sheets data source configuration.
253254
GOOGLESHEETS_EMPTY_ROW=No data found at this row index. Do you want to try inserting something first?

server/openblocks-server/src/main/java/com/openblocks/api/application/ApplicationApiService.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
import com.openblocks.domain.permission.solution.SuggestAppAdminSolution;
6060
import com.openblocks.domain.plugin.service.DatasourceMetaInfoService;
6161
import com.openblocks.domain.solutions.TemplateSolution;
62+
import com.openblocks.domain.template.model.Template;
63+
import com.openblocks.domain.template.service.TemplateService;
6264
import com.openblocks.domain.user.service.UserService;
6365
import com.openblocks.infra.util.TupleUtils;
6466
import com.openblocks.sdk.constants.Authentication;
@@ -120,6 +122,8 @@ public class ApplicationApiService {
120122
private DatasourceMetaInfoService datasourceMetaInfoService;
121123
@Autowired
122124
private CompoundApplicationDslFilter compoundApplicationDslFilter;
125+
@Autowired
126+
private TemplateService templateService;
123127

124128
public Mono<ApplicationView> create(CreateApplicationRequest createApplicationRequest) {
125129

@@ -273,18 +277,21 @@ public Mono<ApplicationView> getPublishedApplication(String applicationId) {
273277
.delayUntil(application -> checkApplicationStatus(application, NORMAL)))
274278
.zipWhen(tuple -> applicationService.getAllDependentModulesFromApplication(tuple.getT2(), true), TupleUtils::merge)
275279
.zipWhen(tuple -> organizationService.getOrgCommonSettings(tuple.getT2().getOrganizationId()), TupleUtils::merge)
280+
.zipWith(getTemplateIdFromApplicationId(applicationId), TupleUtils::merge)
276281
.map(tuple -> {
277282
ResourcePermission permission = tuple.getT1();
278283
Application application = tuple.getT2();
279284
List<Application> dependentModules = tuple.getT3();
280285
Map<String, Object> commonSettings = tuple.getT4();
286+
String templateId = tuple.getT5();
281287
Map<String, Map<String, Object>> dependentModuleDsl = dependentModules.stream()
282288
.collect(Collectors.toMap(Application::getId, app -> sanitizeDsl(app.getLiveApplicationDsl()), (a, b) -> b));
283289
return ApplicationView.builder()
284290
.applicationInfoView(buildView(application, permission.getResourceRole().getValue()))
285291
.applicationDSL(sanitizeDsl(application.getLiveApplicationDsl()))
286292
.moduleDSL(dependentModuleDsl)
287293
.orgCommonSettings(commonSettings)
294+
.templateId(templateId)
288295
.build();
289296
})
290297
.delayUntil(applicationView -> {
@@ -295,6 +302,16 @@ public Mono<ApplicationView> getPublishedApplication(String applicationId) {
295302
});
296303
}
297304

305+
private Mono<String> getTemplateIdFromApplicationId(String applicationId) {
306+
return templateService.getByApplicationId(applicationId)
307+
.map(Template::getId)
308+
.defaultIfEmpty("")
309+
.onErrorResume(e -> {
310+
log.error("get template from applicationId error", e);
311+
return Mono.just("");
312+
});
313+
}
314+
298315
public Mono<Void> updateUserApplicationLastViewTime(String applicationId) {
299316
return sessionUserService.getVisitorId()
300317
.filter(Authentication::isNotAnonymousUser)

server/openblocks-server/src/main/java/com/openblocks/api/application/view/ApplicationView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ public class ApplicationView {
1111
private final ApplicationInfoView applicationInfoView;
1212
private final Map<String, Object> applicationDSL;
1313
private final Map<String, Map<String, Object>> moduleDSL;
14-
1514
private final Map<String, Object> orgCommonSettings;
15+
private final String templateId;
1616
}

server/openblocks-server/src/main/java/com/openblocks/api/authentication/request/form/FormAuthRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ public class FormAuthRequest implements AuthRequest {
2626
public Mono<AuthorizedUser> auth(AuthRequestContext authRequestContext) {
2727
FormAuthRequestContext context = (FormAuthRequestContext) authRequestContext;
2828
return userService.findBySourceAndId(context.getSource(), context.getLoginId())
29+
.switchIfEmpty(ofError(BizError.INVALID_PASSWORD, "INVALID_EMAIL_OR_PASSWORD"))
2930
.flatMap(user -> {
3031
String raw = context.getPassword();
3132
String encoded = user.getPassword();
3233
if (!encryptionService.matchPassword(raw, encoded)) {
33-
return ofError(BizError.INVALID_PASSWORD, "INVALID_PASSWORD");
34+
return ofError(BizError.INVALID_PASSWORD, "INVALID_EMAIL_OR_PASSWORD");
3435
}
3536
AuthorizedUser authorizedUser = AuthorizedUser.builder()
3637
.source(context.getSource())

0 commit comments

Comments
 (0)