Skip to content

Commit d4608d9

Browse files
committed
CLAP-294 Feat: 비밀번호 재설정 인증번호 전송 로직 구현
<footer> - 관련: #346
1 parent adaf9e8 commit d4608d9

File tree

3 files changed

+117
-2
lines changed

3 files changed

+117
-2
lines changed

src/main/java/clap/server/adapter/outbound/api/EmailClient.java

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

33
import clap.server.adapter.outbound.api.dto.EmailTemplate;
44
import clap.server.adapter.outbound.api.dto.PushNotificationTemplate;
5-
import clap.server.application.port.outbound.webhook.SendEmailPort;
5+
import clap.server.application.port.outbound.email.SendEmailPort;
6+
import clap.server.application.port.outbound.webhook.SendWebhookEmailPort;
67
import clap.server.common.annotation.architecture.ExternalApiAdapter;
78
import clap.server.exception.AdapterException;
89
import clap.server.exception.code.NotificationErrorCode;
@@ -13,7 +14,7 @@
1314

1415
@ExternalApiAdapter
1516
@RequiredArgsConstructor
16-
public class EmailClient implements SendEmailPort {
17+
public class EmailClient implements SendEmailPort, SendWebhookEmailPort {
1718

1819
private final EmailTemplateBuilder emailTemplateBuilder;
1920
private final JavaMailSender mailSender;
@@ -51,4 +52,23 @@ public void sendInvitationEmail(String memberEmail, String receiverName, String
5152
throw new AdapterException(NotificationErrorCode.EMAIL_SEND_FAILED);
5253
}
5354
}
55+
56+
@Override
57+
public void sendVerificationEmail(String memberEmail, String receiverName, String verificationCode) {
58+
try {
59+
MimeMessage mimeMessage = mailSender.createMimeMessage();
60+
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
61+
62+
EmailTemplate template = emailTemplateBuilder.createVerificationCodeTemplate(memberEmail, receiverName, verificationCode);
63+
helper.setTo(template.email());
64+
helper.setSubject(template.subject());
65+
helper.setText(template.body(), true);
66+
67+
mailSender.send(mimeMessage);
68+
} catch (Exception e) {
69+
throw new AdapterException(NotificationErrorCode.EMAIL_SEND_FAILED);
70+
}
71+
}
72+
73+
5474
}

src/main/java/clap/server/adapter/outbound/api/EmailTemplateBuilder.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,14 @@ public EmailTemplate createInvitationTemplate(String receiver, String receiverNa
6969
String body = templateEngine.process(templateName, context);
7070
return new EmailTemplate(receiver, subject, body);
7171
}
72+
73+
public EmailTemplate createVerificationCodeTemplate(String receiver, String receiverName, String verificationCode) {
74+
Context context = new Context();
75+
String templateName = "verification";
76+
String subject = "[TaskFlow] 비밀번호 재설정 인증 번호";
77+
context.setVariable("verificationCode", verificationCode);
78+
context.setVariable("receiverName", receiverName);
79+
String body = templateEngine.process(templateName, context);
80+
return new EmailTemplate(receiver, subject, body);
81+
}
7282
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<!DOCTYPE html>
2+
<html lang="ko" xmlns:th="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>[TaskFlow] 비밀번호 재설정 인증 번호 <span th:text="${verificationCode}">인증번호</span></title>
6+
<style>
7+
/* CSS 스타일 */
8+
body {
9+
font-family: Arial, sans-serif;
10+
line-height: 1.6;
11+
background-color: #f9f9f9;
12+
margin: 0;
13+
padding: 0;
14+
}
15+
.email-container {
16+
max-width: 500px;
17+
margin: 20px auto;
18+
background: #ffffff;
19+
border: 1px solid #eaeaea;
20+
border-radius: 8px;
21+
overflow: hidden;
22+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
23+
}
24+
.header {
25+
background-color: #0052cc;
26+
color: #ffffff;
27+
padding: 15px;
28+
text-align: center;
29+
}
30+
.content {
31+
padding: 20px;
32+
color: #333333;
33+
}
34+
.content p {
35+
margin: 10px 0;
36+
}
37+
.cta-button {
38+
text-align: center;
39+
margin: 20px 0;
40+
}
41+
.cta-button a {
42+
background-color: #0052cc;
43+
color: #ffffff;
44+
text-decoration: none;
45+
padding: 10px 20px;
46+
border-radius: 5px;
47+
font-weight: bold;
48+
}
49+
.cta-button a:hover {
50+
background-color: #0041a7;
51+
}
52+
.footer {
53+
text-align: center;
54+
padding: 10px;
55+
font-size: 0.9em;
56+
color: #777777;
57+
background-color: #f4f4f4;
58+
border-top: 1px solid #eaeaea;
59+
}
60+
.footer .taskflow {
61+
font-size: 1.2em; /* 글자 크기 조정 */
62+
font-weight: bold; /* 글자 굵게 */
63+
}
64+
</style>
65+
</head>
66+
<body>
67+
<div class="email-container">
68+
<div class="header">
69+
TaskFlow 초대 서비스
70+
</div>
71+
<div class="content">
72+
<p>안녕하세요, <strong th:text="${receiverName}"></strong>님!</p>
73+
<p>TaskFlow 비밀번호 재설정을 위한 인증번호 입니다.</p>
74+
<ul>
75+
<li>비밀번호 재설정 인증번호: <strong th:text="${verificationCode}"></strong></li>
76+
</ul>
77+
</div>
78+
<div class="footer">
79+
<span class="taskflow">TaskFlow</span><br>
80+
스마트한 업무 관리를 위한<br>
81+
"혁신적인 서비스"
82+
</div>
83+
</div>
84+
</body>
85+
</html>

0 commit comments

Comments
 (0)