Skip to content

Commit 8f6bfe5

Browse files
authored
Merge pull request #934 from lowcoder-org/fix_user_profile_endpoint
Remove password reset template from /me data
2 parents 0808ca3 + cb9d226 commit 8f6bfe5

File tree

5 files changed

+35
-127
lines changed

5 files changed

+35
-127
lines changed

server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/organization/model/Organization.java

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
import static org.apache.commons.lang3.ObjectUtils.firstNonNull;
55
import static org.lowcoder.infra.util.AssetUtils.toAssetPath;
66

7-
import java.util.Collections;
8-
import java.util.HashMap;
9-
import java.util.List;
10-
import java.util.Optional;
7+
import java.util.*;
118

9+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
10+
import com.fasterxml.jackson.annotation.JsonView;
1211
import lombok.experimental.SuperBuilder;
1312
import lombok.extern.jackson.Jacksonized;
1413
import org.apache.commons.lang3.builder.ToStringBuilder;
@@ -17,6 +16,7 @@
1716
import org.lowcoder.domain.mongodb.BeforeMongodbWrite;
1817
import org.lowcoder.domain.mongodb.MongodbInterceptorContext;
1918
import org.lowcoder.sdk.auth.AbstractAuthConfig;
19+
import org.lowcoder.sdk.config.JsonViews;
2020
import org.lowcoder.sdk.models.HasIdAndAuditing;
2121
import org.springframework.data.mongodb.core.mapping.Document;
2222

@@ -88,11 +88,24 @@ public OrganizationCommonSettings getCommonSettings() {
8888
}
8989

9090
public static class OrganizationCommonSettings extends HashMap<String, Object> {
91-
public static final String USER_EXTRA_TRANSFORMER = "userExtraTransformer";
92-
public static final String USER_EXTRA_TRANSFORMER_UPDATE_TIME = "userExtraTransformer_updateTime";
93-
public static final String PASSWORD_RESET_EMAIL_TEMPLATE = "passwordResetEmailTemplate";
94-
// custom branding configs
95-
public static final String CUSTOM_BRANDING_KEY = "branding";
91+
public static final String PASSWORD_RESET_EMAIL_TEMPLATE = "PASSWORD_RESET_EMAIL_TEMPLATE";
92+
93+
/**
94+
* Settings excluded from sanitized export
95+
*/
96+
private final Set<String> excludedKeys = Set.of(
97+
PASSWORD_RESET_EMAIL_TEMPLATE
98+
);
99+
public OrganizationCommonSettings sanitized() {
100+
OrganizationCommonSettings sanitized = new OrganizationCommonSettings();
101+
if (isEmpty()) {
102+
return sanitized;
103+
}
104+
this.entrySet().stream()
105+
.filter((entry) -> !excludedKeys.contains(entry.getKey()))
106+
.forEach((entry) -> sanitized.put(entry.getKey(), entry.getValue()));
107+
return sanitized;
108+
}
96109
}
97110

98111
public long getCreateTime() {

server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/organization/service/OrganizationServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public Mono<Organization> create(Organization organization, String creatorId, bo
141141
return Mono.error(new BizException(BizError.INVALID_PARAMETER, "INVALID_PARAMETER", FieldName.ORGANIZATION));
142142
}
143143
organization.setCommonSettings(new OrganizationCommonSettings());
144-
organization.getCommonSettings().put("PASSWORD_RESET_EMAIL_TEMPLATE",
144+
organization.getCommonSettings().put(OrganizationCommonSettings.PASSWORD_RESET_EMAIL_TEMPLATE,
145145
PASSWORD_RESET_EMAIL_TEMPLATE_DEFAULT);
146146
organization.setState(ACTIVE);
147147
return Mono.just(organization);

server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/user/service/UserServiceImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.lowcoder.domain.group.service.GroupMemberService;
1818
import org.lowcoder.domain.group.service.GroupService;
1919
import org.lowcoder.domain.organization.model.OrgMember;
20+
import org.lowcoder.domain.organization.model.Organization;
2021
import org.lowcoder.domain.organization.service.OrgMemberService;
2122
import org.lowcoder.domain.organization.service.OrganizationService;
2223
import org.lowcoder.domain.user.model.*;
@@ -267,7 +268,7 @@ public Mono<Boolean> lostPassword(String userEmail) {
267268
return findByName(userEmail)
268269
.zipWhen(user -> orgMemberService.getCurrentOrgMember(user.getId())
269270
.flatMap(orgMember -> organizationService.getById(orgMember.getOrgId()))
270-
.map(organization -> organization.getCommonSettings().get("PASSWORD_RESET_EMAIL_TEMPLATE")))
271+
.map(organization -> organization.getCommonSettings().get(Organization.OrganizationCommonSettings.PASSWORD_RESET_EMAIL_TEMPLATE)))
271272
.flatMap(tuple -> {
272273
User user = tuple.getT1();
273274
String emailTemplate = (String)tuple.getT2();

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/home/UserHomeApiServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public Mono<UserProfileView> buildUserProfileView(User user, ServerWebExchange e
109109
return Mono.zip(orgAndRolesMono, orgDevChecker.isCurrentOrgDev())
110110
.map(tuple2 -> {
111111
List<OrgAndVisitorRoleView> orgAndRoles = tuple2.getT1();
112+
orgAndRoles.forEach(orgAndRole -> orgAndRole.getOrg().setCommonSettings(orgAndRole.getOrg().getCommonSettings().sanitized()));
112113
boolean isOrgDev = tuple2.getT2();
113114
return UserProfileView.builder()
114115
.id(user.getId())
Lines changed: 9 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,24 @@
1-
auth:
2-
api-key:
3-
secret: ${LOWCODER_API_KEY_SECRET:5a41b090758b39b226603177ef48d73ae9839dd458ccb7e66f7e7cc028d5a50b}
4-
email:
5-
enable: ${LOWCODER_EMAIL_AUTH_ENABLED:true}
6-
enable-register: ${LOWCODER_EMAIL_SIGNUP_ENABLED:true}
7-
workspace-creation: ${LOWCODER_CREATE_WORKSPACE_ON_SIGNUP:true}
8-
91
spring:
102
data:
113
mongodb:
124
authentication-database: admin
13-
auto-index-creation: false
14-
uri: ${LOWCODER_MONGODB_URL:mongodb://lowcoder:secret123@localhost:27017/lowcoder?retryWrites=true&loadBalanced=false&connectTimeoutMS=10000&authSource=admin&authMechanism=SCRAM-SHA-256}
5+
uri: "mongodb://lowcoder:secret123@127.0.0.1:37017/lowcoder?authSource=admin"
156
redis:
16-
url: ${LOWCODER_REDIS_URL:redis://localhost:6379}
17-
main:
18-
allow-bean-definition-overriding: false
19-
allow-circular-references: false
20-
codec:
21-
max-in-memory-size: 20MB
22-
webflux:
23-
base-path: /
24-
mail:
25-
host: ${LOWCODER_ADMIN_SMTP_HOST:localhost}
26-
port: ${LOWCODER_ADMIN_SMTP_PORT:587}
27-
username: ${LOWCODER_ADMIN_SMTP_USERNAME:info@localhost}
28-
password: ${LOWCODER_ADMIN_SMTP_PASSWORD:s3cr3t}
29-
properties:
30-
mail:
31-
smtp:
32-
auth: ${LOWCODER_ADMIN_SMTP_AUTH:true}
33-
ssl:
34-
enable: ${LOWCODER_ADMIN_SMTP_SSL_ENABLED:false}
35-
starttls:
36-
enable: ${LOWCODER_ADMIN_SMTP_STARTTLS_ENABLED:true}
37-
required: ${LOWCODER_ADMIN_SMTP_STARTTLS_REQUIRED:true}
38-
transport:
39-
protocol: smtp
40-
server:
41-
compression:
42-
enabled: true
43-
forward-headers-strategy: NATIVE
44-
http2:
45-
enabled: true
46-
port: 8080
47-
shutdown: graceful
48-
49-
default:
50-
orgs-per-user: ${LOWCODER_MAX_ORGS_PER_USER:100}
51-
org-member-count: ${LOWCODER_MAX_MEMBERS_PER_ORG:1000}
52-
org-group-count: ${LOWCODER_MAX_GROUPS_PER_ORG:100}
53-
org-app-count: ${LOWCODER_MAX_APPS_PER_ORG:1000}
54-
developer-count: ${LOWCODER_MAX_DEVELOPERS:50}
55-
api-rate-limit: ${LOWCODER_API_RATE_LIMIT:50}
7+
url: "redis://127.0.0.1:16379"
568

9+
server:
10+
port: 18080
5711
common:
58-
cookie-name: LOWCODER_CE_SELFHOST_TOKEN
59-
product: lowcoder
60-
domain:
61-
default-value: lowcoder.org
62-
cloud: false
63-
version: 2.1.4
64-
apiVersion: 1.1
65-
block-hound-enable: false
66-
encrypt:
67-
password: ${LOWCODER_DB_ENCRYPTION_PASSWORD:lowcoder.org}
68-
salt: ${LOWCODER_DB_ENCRYPTION_SALT:lowcoder.org}
69-
security:
70-
corsAllowedDomainString: ${LOWCODER_CORS_DOMAINS:*}
12+
cookie-name: LOWCODER_DEBUG_TOKEN
7113
js-executor:
72-
host: ${LOWCODER_NODE_SERVICE_URL:http://127.0.0.1:6060}
73-
max-query-request-size: ${LOWCODER_MAX_REQUEST_SIZE:20m}
74-
max-query-response-size: ${LOWCODER_MAX_REQUEST_SIZE:20m}
75-
max-upload-size: ${LOWCODER_MAX_REQUEST_SIZE:20m}
76-
max-query-timeout: ${LOWCODER_MAX_QUERY_TIMEOUT:120}
14+
host: "http://127.0.0.1:16060"
7715
workspace:
78-
mode: ${LOWCODER_WORKSPACE_MODE:SAAS}
79-
plugin-dirs:
80-
- ${LOWCODER_PLUGINS_DIR:../plugins}
81-
super-admin:
82-
username: ${LOWCODER_SUPERUSER_USERNAME:admin@localhost}
83-
password: ${LOWCODER_SUPERUSER_PASSWORD:}
84-
marketplace:
85-
private-mode: ${LOWCODER_MARKETPLACE_PRIVATE_MODE:true}
86-
lowcoder-public-url: ${LOWCODER_PUBLIC_URL:http://localhost:3000}
87-
notifications-email-sender: ${LOWCODER_EMAIL_NOTIFICATIONS_SENDER:info@localhost}
88-
89-
material:
90-
mongodb-grid-fs:
91-
bucket-name: material
92-
93-
springdoc:
94-
api-docs:
95-
path: /api/docs/openapi.json
96-
swagger-ui:
97-
path: /api/docs/swagger-ui
98-
paths-to-exclude: /api/v1/**
99-
100-
management:
101-
endpoints:
102-
enabled-by-default: false
103-
web:
104-
base-path: "/api/status"
105-
exposure:
106-
include: "health,metrics,prometheus"
107-
endpoint:
108-
health:
109-
show-details: never
110-
show-components: always
111-
enabled: true
112-
metrics:
113-
enabled: true
114-
prometheus:
115-
enabled: true
116-
health:
117-
mail:
118-
enabled: false
119-
db:
120-
enabled: true
121-
redis:
122-
enabled: true
123-
diskspace:
124-
enabled: false
16+
mode: SAAS
12517

12618
debug: true
12719

12820
logging:
12921
level:
13022
root: debug
131-
org.lowcoder: debug
23+
org.lowcoder: debug
24+

0 commit comments

Comments
 (0)