Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 65d9e2a

Browse files
committed
Misc fixes
1 parent 0a213f4 commit 65d9e2a

File tree

5 files changed

+15
-30
lines changed

5 files changed

+15
-30
lines changed

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import jakarta.mail.internet.MimeMessage;
44
import lombok.extern.slf4j.Slf4j;
5+
import org.lowcoder.sdk.config.CommonConfig;
56
import org.springframework.beans.factory.annotation.Autowired;
6-
import org.springframework.beans.factory.annotation.Value;
77
import org.springframework.mail.javamail.JavaMailSender;
88
import org.springframework.mail.javamail.MimeMessageHelper;
99
import org.springframework.stereotype.Service;
@@ -15,25 +15,22 @@ public class EmailCommunicationService {
1515
@Autowired
1616
private JavaMailSender javaMailSender;
1717

18-
@Value("${spring.mail.username}")
19-
private String fromEmail;
20-
21-
@Value("${common.lowcoder_public_url}")
22-
private String lowcoderPublicUrl;
18+
@Autowired
19+
private CommonConfig config;
2320

2421
public boolean sendPasswordResetEmail(String to, String token, String message) {
2522
try {
26-
String subject = "Reset Your Password";
23+
String subject = "Reset Your Lost Password";
2724
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
2825

2926
MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, true);
3027

31-
mimeMessageHelper.setFrom(fromEmail);
28+
mimeMessageHelper.setFrom(config.getLostPasswordEmailSender());
3229
mimeMessageHelper.setTo(to);
3330
mimeMessageHelper.setSubject(subject);
3431

3532
// Construct the message with the token link
36-
String resetLink = lowcoderPublicUrl + "/api/users/lost-password/" + token;
33+
String resetLink = config.getLowcoderPublicUrl() + "lost-password?token=" + token;
3734
String formattedMessage = String.format(message, to, resetLink);
3835
mimeMessageHelper.setText(formattedMessage, true); // Set HTML to true to allow links
3936

@@ -42,7 +39,7 @@ public boolean sendPasswordResetEmail(String to, String token, String message) {
4239
return true;
4340

4441
} catch (Exception e) {
45-
log.error("Failed to send mail to: {}, Exception: {}", to, e);
42+
log.error("Failed to send mail to: {}, Exception: ", to, e);
4643
return false;
4744
}
4845

server/api-service/lowcoder-sdk/src/main/java/org/lowcoder/sdk/config/CommonConfig.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public class CommonConfig {
4545
private JsExecutor jsExecutor = new JsExecutor();
4646
private Set<String> disallowedHosts = new HashSet<>();
4747
private Marketplace marketplace = new Marketplace();
48-
private SMTP smtp = new SMTP();
48+
private String lowcoderPublicUrl;
49+
private String lostPasswordEmailSender;
4950

5051
public boolean isSelfHost() {
5152
return !isCloud();
@@ -147,13 +148,6 @@ public static class JsExecutor {
147148
private String host;
148149
}
149150

150-
@Data
151-
public static class SMTP {
152-
private String email;
153-
private String host;
154-
private String port;
155-
}
156-
157151
@Data
158152
public static class Marketplace {
159153

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/framework/security/SecurityConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
113113

114114
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, USER_URL + "/me"),
115115
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, USER_URL + "/currentUser"),
116+
ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, USER_URL + "/lost-password"),
116117

117118
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, GROUP_URL + "/list"), // application view
118119
ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, QUERY_URL + "/execute"), // application view
@@ -139,6 +140,7 @@ SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
139140
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.APPLICATION_URL + "/marketplace-apps"), // marketplace apps
140141
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.USER_URL + "/me"),
141142
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.USER_URL + "/currentUser"),
143+
ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, NewUrl.USER_URL + "/lost-password"),
142144
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.GROUP_URL + "/list"),
143145
ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, NewUrl.QUERY_URL + "/execute"),
144146
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.MATERIAL_URL + "/**"),

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/usermanagement/UserController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public Mono<ResponseView<String>> resetPassword(@RequestBody ResetPasswordReques
149149
@Override
150150
public Mono<ResponseView<Boolean>> lostPassword(@RequestBody LostPasswordRequest request) {
151151
if (StringUtils.isBlank(request.userEmail())) {
152-
return ofError(BizError.INVALID_PARAMETER, "INVALID_USER_EMAIL");
152+
return ofError(BizError.INVALID_PARAMETER, "INVALID_PARAMETER");
153153
}
154154
return userApiService.lostPassword(request.userEmail())
155155
.map(ResponseView::success);

server/api-service/lowcoder-server/src/main/resources/application-lowcoder.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,8 @@ spring:
1010
allow-bean-definition-overriding: true
1111
allow-circular-references: true
1212
mail:
13-
# TODO - IRFAN this is just a test email to check the email sending.
14-
username: "[email protected]"
15-
password: "abcd"
16-
host: "smtp.freesmtpservers.com"
13+
host: smtp.freesmtpservers.com
1714
port: 25
18-
# properties:
19-
# mail:
20-
# smtp:
21-
# starttls:
22-
# enable: true
23-
# auth: true
2415

2516
server:
2617
compression:
@@ -58,7 +49,8 @@ common:
5849
host: http://127.0.0.1:6060
5950
marketplace:
6051
private-mode: false
61-
lowcoder_public_url: http://localhost:8080
52+
lowcoder-public-url: http://localhost:8080
53+
lost-password-email-sender: [email protected]
6254

6355
material:
6456
mongodb-grid-fs:

0 commit comments

Comments
 (0)