Skip to content

Commit dd1d73d

Browse files
committed
Email template
1 parent 70985bd commit dd1d73d

File tree

4 files changed

+274
-14
lines changed

4 files changed

+274
-14
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>com.github.throyer.common.spring-boot</groupId>
1212
<artifactId>api</artifactId>
13-
<version>3.0.0</version>
13+
<version>3.0.1</version>
1414
<name>Common API</name>
1515
<description>Exemplo de api simples com Spring Boot</description>
1616

src/main/java/com/github/throyer/common/springboot/domain/models/emails/RecoveryEmail.java

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,37 @@
55
import org.thymeleaf.context.Context;
66

77
public class RecoveryEmail implements Email {
8+
9+
private static final Integer FIRST = 0;
10+
private static final Integer SECOND = 1;
11+
private static final Integer THIRD = 2;
12+
private static final Integer FOURTH = 3;
813

9-
private String destination;
10-
private String subject;
11-
private String recoveryCode;
14+
private final String destination;
15+
private final String subject;
16+
private final String name;
17+
18+
private final String first;
19+
private final String second;
20+
private final String third;
21+
private final String fourth;
1222

13-
public RecoveryEmail(String destination, String subject, String recoveryCode) {
23+
public RecoveryEmail(
24+
String destination,
25+
String subject,
26+
String name,
27+
String recoveryCode
28+
) {
1429
this.destination = destination;
1530
this.subject = subject;
16-
this.recoveryCode = recoveryCode;
31+
this.name = name;
32+
33+
var code = recoveryCode.split("");
34+
35+
this.first = code[FIRST];
36+
this.second = code[SECOND];
37+
this.third = code[THIRD];
38+
this.fourth = code[FOURTH];
1739
}
1840

1941
@Override
@@ -34,7 +56,14 @@ public String getTemplate() {
3456
@Override
3557
public Context getContext() {
3658
var context = new Context();
37-
context.setVariable("code", recoveryCode);
59+
60+
context.setVariable("name", this.name);
61+
62+
context.setVariable("first", this.first);
63+
context.setVariable("second", this.second);
64+
context.setVariable("third", this.third);
65+
context.setVariable("fourth", this.fourth);
66+
3867
return context;
3968
}
4069

src/main/java/com/github/throyer/common/springboot/domain/services/recovery/RecoveryService.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
@Service
1717
public class RecoveryService {
18+
19+
private static final Integer MINUTES_TO_EXPIRE = 20;
1820

1921
@Autowired
2022
private UserRepository users;
@@ -49,14 +51,18 @@ public void recovery(String email) {
4951
return;
5052
}
5153

52-
var minutesToExpire = 20;
53-
54-
var recovery = new Recovery(user.get(), minutesToExpire);
54+
var recovery = new Recovery(user.get(), MINUTES_TO_EXPIRE);
5555

5656
recoveries.save(recovery);
5757

5858
try {
59-
var recoveryEmail = new RecoveryEmail(email, "password recovery code", recovery.getCode());
59+
var recoveryEmail = new RecoveryEmail(
60+
email,
61+
"password recovery code",
62+
user.get().getName(),
63+
recovery.getCode()
64+
);
65+
6066
service.send(recoveryEmail);
6167
} catch (Exception exception) { }
6268
}
Lines changed: 228 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,230 @@
1+
<html>
2+
3+
<head>
4+
<style>
5+
* {
6+
font-family: Arial, sans-serif !important;
7+
}
8+
9+
html {
10+
background: white;
11+
}
12+
13+
.main {
14+
margin: auto;
15+
width: 600px !important;
16+
background: #e5e5e5;
17+
}
18+
19+
table {
20+
border-collapse: collapse;
21+
}
22+
23+
.container {
24+
padding: 0 30px;
25+
}
26+
27+
.title {
28+
text-align: center;
29+
font-style: normal;
30+
font-weight: 600;
31+
font-size: 20px;
32+
}
33+
34+
.description {
35+
font-style: normal;
36+
font-weight: normal;
37+
font-size: 12px;
38+
text-align: center;
39+
padding-top: 15px;
40+
color: #b3b5bb;
41+
}
42+
43+
.text {
44+
font-style: normal;
45+
font-weight: normal;
46+
font-size: 14px;
47+
line-height: 125%;
48+
color: #424656;
49+
text-align: justify;
50+
padding-top: 30px;
51+
}
52+
53+
.insert-your-code {
54+
font-size: 14px;
55+
line-height: 125%;
56+
text-align: center;
57+
color: #868993;
58+
padding-top: 40px;
59+
}
60+
61+
.your-code {
62+
font-weight: 600;
63+
font-size: 20px;
64+
text-align: center;
65+
letter-spacing: -0.02em;
66+
color: #7962f7;
67+
padding-top: 8px;
68+
}
69+
70+
.table-code-box {
71+
margin-top: 24px;
72+
}
73+
74+
.code-box {
75+
width: 88px;
76+
height: 88px;
77+
background: #7962f7;
78+
box-shadow: 0px 12px 12px rgba(66, 70, 86, 0.08),
79+
0px 16px 24px rgba(66, 70, 86, 0.08);
80+
border-radius: 16px;
81+
text-align: center;
82+
color: #ffffff;
83+
margin: 10px 0px;
84+
font-size: 56px;
85+
}
86+
87+
.code-box-spacing {
88+
width: 16px;
89+
}
90+
91+
.disclaimer {
92+
font-style: normal;
93+
font-weight: normal;
94+
font-size: 14px;
95+
padding-top: 80px;
96+
text-align: center;
97+
color: #868993;
98+
}
99+
100+
.footer-1 {
101+
margin-top: 65px;
102+
}
103+
104+
.footer-infos {
105+
width: 63%;
106+
background: #ffffff;
107+
border-radius: 16px 16px 0px 0px;
108+
}
109+
110+
.footer-infos .logo img {
111+
width: 230px;
112+
}
113+
114+
.footer-infos .site {
115+
padding-top: 15px;
116+
}
117+
118+
.footer-infos .site a {
119+
text-decoration: none;
120+
font-style: normal;
121+
font-weight: 500;
122+
font-size: 10px;
123+
letter-spacing: 0.16em;
124+
text-transform: uppercase;
125+
color: #9597a0;
126+
}
127+
128+
.footer-infos-separator {
129+
padding-top: 16px;
130+
}
131+
132+
.footer-infos-separator img {
133+
width: 64px;
134+
}
135+
136+
.footer-infos-social {
137+
font-style: normal;
138+
font-weight: 600;
139+
font-size: 12px;
140+
line-height: 100%;
141+
color: #424656;
142+
padding-top: 15px;
143+
}
144+
145+
.footer-infos-social-logo img {
146+
height: 22px;
147+
padding-right: 20px;
148+
padding-top: 14px;
149+
}
150+
151+
.footer-stores {
152+
height: 220px;
153+
background: #0ad3e8;
154+
border-radius: 16px 16px 0px 0px;
155+
width: 220px;
156+
}
157+
158+
.footer-stores img {
159+
width: 150px;
160+
}
161+
</style>
162+
</head>
1163

2164
<body>
3-
Your recovery code
4-
<h1 th:text="${code}"></h1>
5-
</body>
165+
<table align="center" class="main">
166+
<table align="center">
167+
<tbody>
168+
<tr>
169+
<td>
170+
<img src="https://i.imgur.com/UJ9JMCC.png" width="200" alt="Header" />
171+
</td>
172+
</tr>
173+
</tbody>
174+
</table>
175+
<table align="center">
176+
<tbody>
177+
<tr>
178+
<td class="title">Esqueceu sua senha?</td>
179+
</tr>
180+
<tr>
181+
<td class="text container">
182+
<span th:text="${name}">name</span>, recebemos uma solicitação para que sua
183+
senha fosse redefinida.
184+
</td>
185+
</tr>
186+
<tr>
187+
<td class="insert-your-code">
188+
Insira o código abaixo formulario.
189+
</td>
190+
</tr>
191+
<tr>
192+
<td class="your-code">Seu código de verificação é:</td>
193+
</tr>
194+
</tbody>
195+
</table>
196+
<table align="center" class="table-code-box">
197+
<tbody>
198+
<tr>
199+
<td th:text="${first}" class="code-box">
200+
first
201+
</td>
202+
<td class="code-box-spacing"></td>
203+
<td th:text="${second}" class="code-box">
204+
second
205+
</td>
206+
<td class="code-box-spacing"></td>
207+
<td th:text="${third}" class="code-box">
208+
third
209+
</td>
210+
<td class="code-box-spacing"></td>
211+
<td th:text="${fourth}" class="code-box">
212+
fourth
213+
</td>
214+
</tr>
215+
</tbody>
216+
</table>
217+
<table align="center">
218+
<tbody>
219+
<tr>
220+
<td class="disclaimer container">
221+
Se você não solicitou um pedido de redefinição de
222+
senha por favor ignore este e-mail.
223+
</td>
224+
</tr>
225+
</tbody>
226+
</table>
227+
</table>
228+
</body>
229+
230+
</html>

0 commit comments

Comments
 (0)