Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
fix: remove password reset template from user profile endpoint data
  • Loading branch information
ludomikula committed Jun 5, 2024
commit cb9d2267da2e9881ad83609b10e6466dc0a42b49
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import static org.apache.commons.lang3.ObjectUtils.firstNonNull;
import static org.lowcoder.infra.util.AssetUtils.toAssetPath;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.*;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;
import org.apache.commons.lang3.builder.ToStringBuilder;
Expand All @@ -17,6 +16,7 @@
import org.lowcoder.domain.mongodb.BeforeMongodbWrite;
import org.lowcoder.domain.mongodb.MongodbInterceptorContext;
import org.lowcoder.sdk.auth.AbstractAuthConfig;
import org.lowcoder.sdk.config.JsonViews;
import org.lowcoder.sdk.models.HasIdAndAuditing;
import org.springframework.data.mongodb.core.mapping.Document;

Expand Down Expand Up @@ -88,11 +88,24 @@ public OrganizationCommonSettings getCommonSettings() {
}

public static class OrganizationCommonSettings extends HashMap<String, Object> {
public static final String USER_EXTRA_TRANSFORMER = "userExtraTransformer";
public static final String USER_EXTRA_TRANSFORMER_UPDATE_TIME = "userExtraTransformer_updateTime";
public static final String PASSWORD_RESET_EMAIL_TEMPLATE = "passwordResetEmailTemplate";
// custom branding configs
public static final String CUSTOM_BRANDING_KEY = "branding";
public static final String PASSWORD_RESET_EMAIL_TEMPLATE = "PASSWORD_RESET_EMAIL_TEMPLATE";

/**
* Settings excluded from sanitized export
*/
private final Set<String> excludedKeys = Set.of(
PASSWORD_RESET_EMAIL_TEMPLATE
);
public OrganizationCommonSettings sanitized() {
OrganizationCommonSettings sanitized = new OrganizationCommonSettings();
if (isEmpty()) {
return sanitized;
}
this.entrySet().stream()
.filter((entry) -> !excludedKeys.contains(entry.getKey()))
.forEach((entry) -> sanitized.put(entry.getKey(), entry.getValue()));
return sanitized;
}
}

public long getCreateTime() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public Mono<Organization> create(Organization organization, String creatorId, bo
return Mono.error(new BizException(BizError.INVALID_PARAMETER, "INVALID_PARAMETER", FieldName.ORGANIZATION));
}
organization.setCommonSettings(new OrganizationCommonSettings());
organization.getCommonSettings().put("PASSWORD_RESET_EMAIL_TEMPLATE",
organization.getCommonSettings().put(OrganizationCommonSettings.PASSWORD_RESET_EMAIL_TEMPLATE,
PASSWORD_RESET_EMAIL_TEMPLATE_DEFAULT);
organization.setState(ACTIVE);
return Mono.just(organization);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.lowcoder.domain.group.service.GroupMemberService;
import org.lowcoder.domain.group.service.GroupService;
import org.lowcoder.domain.organization.model.OrgMember;
import org.lowcoder.domain.organization.model.Organization;
import org.lowcoder.domain.organization.service.OrgMemberService;
import org.lowcoder.domain.organization.service.OrganizationService;
import org.lowcoder.domain.user.model.*;
Expand Down Expand Up @@ -267,7 +268,7 @@ public Mono<Boolean> lostPassword(String userEmail) {
return findByName(userEmail)
.zipWhen(user -> orgMemberService.getCurrentOrgMember(user.getId())
.flatMap(orgMember -> organizationService.getById(orgMember.getOrgId()))
.map(organization -> organization.getCommonSettings().get("PASSWORD_RESET_EMAIL_TEMPLATE")))
.map(organization -> organization.getCommonSettings().get(Organization.OrganizationCommonSettings.PASSWORD_RESET_EMAIL_TEMPLATE)))
.flatMap(tuple -> {
User user = tuple.getT1();
String emailTemplate = (String)tuple.getT2();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public Mono<UserProfileView> buildUserProfileView(User user, ServerWebExchange e
return Mono.zip(orgAndRolesMono, orgDevChecker.isCurrentOrgDev())
.map(tuple2 -> {
List<OrgAndVisitorRoleView> orgAndRoles = tuple2.getT1();
orgAndRoles.forEach(orgAndRole -> orgAndRole.getOrg().setCommonSettings(orgAndRole.getOrg().getCommonSettings().sanitized()));
boolean isOrgDev = tuple2.getT2();
return UserProfileView.builder()
.id(user.getId())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,131 +1,24 @@
auth:
api-key:
secret: ${LOWCODER_API_KEY_SECRET:5a41b090758b39b226603177ef48d73ae9839dd458ccb7e66f7e7cc028d5a50b}
email:
enable: ${LOWCODER_EMAIL_AUTH_ENABLED:true}
enable-register: ${LOWCODER_EMAIL_SIGNUP_ENABLED:true}
workspace-creation: ${LOWCODER_CREATE_WORKSPACE_ON_SIGNUP:true}

spring:
data:
mongodb:
authentication-database: admin
auto-index-creation: false
uri: ${LOWCODER_MONGODB_URL:mongodb://lowcoder:secret123@localhost:27017/lowcoder?retryWrites=true&loadBalanced=false&connectTimeoutMS=10000&authSource=admin&authMechanism=SCRAM-SHA-256}
uri: "mongodb://lowcoder:secret123@127.0.0.1:37017/lowcoder?authSource=admin"
redis:
url: ${LOWCODER_REDIS_URL:redis://localhost:6379}
main:
allow-bean-definition-overriding: false
allow-circular-references: false
codec:
max-in-memory-size: 20MB
webflux:
base-path: /
mail:
host: ${LOWCODER_ADMIN_SMTP_HOST:localhost}
port: ${LOWCODER_ADMIN_SMTP_PORT:587}
username: ${LOWCODER_ADMIN_SMTP_USERNAME:info@localhost}
password: ${LOWCODER_ADMIN_SMTP_PASSWORD:s3cr3t}
properties:
mail:
smtp:
auth: ${LOWCODER_ADMIN_SMTP_AUTH:true}
ssl:
enable: ${LOWCODER_ADMIN_SMTP_SSL_ENABLED:false}
starttls:
enable: ${LOWCODER_ADMIN_SMTP_STARTTLS_ENABLED:true}
required: ${LOWCODER_ADMIN_SMTP_STARTTLS_REQUIRED:true}
transport:
protocol: smtp
server:
compression:
enabled: true
forward-headers-strategy: NATIVE
http2:
enabled: true
port: 8080
shutdown: graceful

default:
orgs-per-user: ${LOWCODER_MAX_ORGS_PER_USER:100}
org-member-count: ${LOWCODER_MAX_MEMBERS_PER_ORG:1000}
org-group-count: ${LOWCODER_MAX_GROUPS_PER_ORG:100}
org-app-count: ${LOWCODER_MAX_APPS_PER_ORG:1000}
developer-count: ${LOWCODER_MAX_DEVELOPERS:50}
api-rate-limit: ${LOWCODER_API_RATE_LIMIT:50}
url: "redis://127.0.0.1:16379"

server:
port: 18080
common:
cookie-name: LOWCODER_CE_SELFHOST_TOKEN
product: lowcoder
domain:
default-value: lowcoder.org
cloud: false
version: 2.1.4
apiVersion: 1.1
block-hound-enable: false
encrypt:
password: ${LOWCODER_DB_ENCRYPTION_PASSWORD:lowcoder.org}
salt: ${LOWCODER_DB_ENCRYPTION_SALT:lowcoder.org}
security:
corsAllowedDomainString: ${LOWCODER_CORS_DOMAINS:*}
cookie-name: LOWCODER_DEBUG_TOKEN
js-executor:
host: ${LOWCODER_NODE_SERVICE_URL:http://127.0.0.1:6060}
max-query-request-size: ${LOWCODER_MAX_REQUEST_SIZE:20m}
max-query-response-size: ${LOWCODER_MAX_REQUEST_SIZE:20m}
max-upload-size: ${LOWCODER_MAX_REQUEST_SIZE:20m}
max-query-timeout: ${LOWCODER_MAX_QUERY_TIMEOUT:120}
host: "http://127.0.0.1:16060"
workspace:
mode: ${LOWCODER_WORKSPACE_MODE:SAAS}
plugin-dirs:
- ${LOWCODER_PLUGINS_DIR:../plugins}
super-admin:
username: ${LOWCODER_SUPERUSER_USERNAME:admin@localhost}
password: ${LOWCODER_SUPERUSER_PASSWORD:}
marketplace:
private-mode: ${LOWCODER_MARKETPLACE_PRIVATE_MODE:true}
lowcoder-public-url: ${LOWCODER_PUBLIC_URL:http://localhost:3000}
notifications-email-sender: ${LOWCODER_EMAIL_NOTIFICATIONS_SENDER:info@localhost}

material:
mongodb-grid-fs:
bucket-name: material

springdoc:
api-docs:
path: /api/docs/openapi.json
swagger-ui:
path: /api/docs/swagger-ui
paths-to-exclude: /api/v1/**

management:
endpoints:
enabled-by-default: false
web:
base-path: "/api/status"
exposure:
include: "health,metrics,prometheus"
endpoint:
health:
show-details: never
show-components: always
enabled: true
metrics:
enabled: true
prometheus:
enabled: true
health:
mail:
enabled: false
db:
enabled: true
redis:
enabled: true
diskspace:
enabled: false
mode: SAAS

debug: true

logging:
level:
root: debug
org.lowcoder: debug
org.lowcoder: debug