update 邮箱验证码模版修改
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.m2pool.lease.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
@@ -638,12 +637,10 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
* @param code
|
||||
*/
|
||||
public void sendLoginCodeMailMessage(String to, String code) {
|
||||
//String subject = "用户登录,邮箱验证码";
|
||||
//String text = "登录验证码10分钟内有效:\n\t"+code;
|
||||
Map<String, Object> content = new HashMap<>();
|
||||
content.put("code",code);
|
||||
content.put("text","Login verification code is valid within 10 minutes");
|
||||
EmailTemplateEntity entity = new EmailTemplateEntity(to,"User login, email verification code","emailCode-en",content);
|
||||
EmailTemplateEntity entity = new EmailTemplateEntity(to,"User login, email verification code","power_leasingEmail",content);
|
||||
sendHtmlEmail(entity.getEmail(),entity.getSubject(),entity.getTemplateName(),entity.getData());
|
||||
}
|
||||
|
||||
@@ -653,35 +650,37 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
* @param code
|
||||
*/
|
||||
public void sendRegisterMessage(String to, String code) {
|
||||
//String subject = "账号注册,邮箱验证码";
|
||||
//String text = "注册验证码10分钟内有效:\n\t"+code;
|
||||
Map<String, Object> content = new HashMap<>();
|
||||
content.put("code",code);
|
||||
content.put("text","The verification code for registration is valid for 10 minutes");
|
||||
EmailTemplateEntity message = new EmailTemplateEntity(to,"Account registration, email verification code","emailCode-en",content);
|
||||
EmailTemplateEntity message = new EmailTemplateEntity(to,"Account registration, email verification code","power_leasingEmail",content);
|
||||
sendHtmlEmail(message.getEmail(),message.getSubject(),message.getTemplateName(),message.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送修改密码的邮件
|
||||
* @param to
|
||||
* @param code
|
||||
*/
|
||||
public void sendUpdatePwdMailMessage(String to, String code) {
|
||||
//String subject = "修改密码,邮箱验证码";
|
||||
//String text = "您正在修改密码,如果不是您本人操作,请忽略。验证码10分钟内有效:\n\t"+code;
|
||||
|
||||
Map<String, Object> content = new HashMap<>();
|
||||
content.put("code",code);
|
||||
content.put("text","You are currently modifying your password. If this is not done by you, please ignore it. The verification code is valid for 10 minutes.");
|
||||
EmailTemplateEntity entity = new EmailTemplateEntity(to,"Change password, email verification code","emailCode-en",content);
|
||||
EmailTemplateEntity entity = new EmailTemplateEntity(to,"Change password, email verification code","power_leasingEmail",content);
|
||||
sendHtmlEmail(entity.getEmail(),entity.getSubject(),entity.getTemplateName(),entity.getData());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送注销账户邮件
|
||||
* @param to
|
||||
* @param code
|
||||
*/
|
||||
public void sendCloseAccountMailMessage(String to, String code) {
|
||||
//String subject = "修改密码,邮箱验证码";
|
||||
//String text = "您正在修改密码,如果不是您本人操作,请忽略。验证码10分钟内有效:\n\t"+code;
|
||||
|
||||
Map<String, Object> content = new HashMap<>();
|
||||
content.put("code",code);
|
||||
content.put("text","You are logging out of the user account. If this is not done by you, please ignore it. The verification code is valid for 10 minutes.");
|
||||
EmailTemplateEntity entity = new EmailTemplateEntity(to,"Change password, email verification code","emailCode-en",content);
|
||||
EmailTemplateEntity entity = new EmailTemplateEntity(to,"Change password, email verification code","power_leasingEmail",content);
|
||||
sendHtmlEmail(entity.getEmail(),entity.getSubject(),entity.getTemplateName(),entity.getData());
|
||||
}
|
||||
/**
|
||||
@@ -839,8 +838,6 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
if(StringUtils.isEmpty(email)){
|
||||
return Result.fail("token解析异常");
|
||||
}
|
||||
boolean success ;
|
||||
|
||||
//判断用户是不是恶意刷邮箱,在规定时间内进行的
|
||||
String redisKey = RedisAuthKey.getGoogleBindCodeKey( email);
|
||||
if (redisService.hasKey(redisKey)) {
|
||||
@@ -857,7 +854,7 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
long overTime = redisService.getExpire(redisKey);
|
||||
redisService.setCacheObject(redisKey, emailCodeValue, overTime, TimeUnit.SECONDS
|
||||
);
|
||||
success = sendEmail(email,emailCode);
|
||||
sendBindGoogleEmail(email,emailCode);
|
||||
}
|
||||
} else {
|
||||
String emailCode = CodeUtils.creatCode(6);
|
||||
@@ -871,38 +868,24 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
redisService.setCacheObject(redisKey, emailCodeValue,
|
||||
10L, TimeUnit.MINUTES
|
||||
);
|
||||
success = sendEmail(email,emailCode);
|
||||
sendBindGoogleEmail(email,emailCode);
|
||||
}
|
||||
|
||||
return success ? Result.success("发送邮箱验证码成功") : Result.fail("发送邮箱验证码失败,请稍后重试");
|
||||
return Result.success("发送邮箱验证码成功");
|
||||
}
|
||||
|
||||
public boolean sendEmail(String email,String code){
|
||||
String text = "您正在绑定谷歌验证器!\n" +
|
||||
"您的邮箱验证验证码是:\n\t"+code +
|
||||
"\n此验证码10分钟有效。";
|
||||
try {
|
||||
//true 代表支持复杂的类型
|
||||
MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(javaMailSender.createMimeMessage(),true);
|
||||
//邮件发信人
|
||||
mimeMessageHelper.setFrom(sendMailer);
|
||||
//邮件收信人 1或多个
|
||||
mimeMessageHelper.setTo(email);
|
||||
//邮件主题
|
||||
mimeMessageHelper.setSubject("[M2Pool] 邮箱验证码");
|
||||
//邮件内容
|
||||
mimeMessageHelper.setText(text);
|
||||
//邮件发送时间
|
||||
mimeMessageHelper.setSentDate(new Date());
|
||||
/**
|
||||
* 发送绑定谷歌双重验证邮箱验证码
|
||||
* @param to
|
||||
* @param code
|
||||
*/
|
||||
public void sendBindGoogleEmail(String to, String code){
|
||||
Map<String, Object> content = new HashMap<>();
|
||||
content.put("code",code);
|
||||
content.put("text","The validity period for binding Google two-factor authentication email verification code is 10 minutes");
|
||||
EmailTemplateEntity message = new EmailTemplateEntity(to,"Bind Google two-factor authentication, email verification code","power_leasingEmail",content);
|
||||
sendHtmlEmail(message.getEmail(),message.getSubject(),message.getTemplateName(),message.getData());
|
||||
|
||||
//发送邮件
|
||||
javaMailSender.send(mimeMessageHelper.getMimeMessage());
|
||||
//System.out.println("发送邮件成功:"+sendMailer+"->"+to);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
System.out.println("发送邮件失败:"+e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -912,7 +895,6 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
return Result.fail("token解析异常");
|
||||
}
|
||||
|
||||
boolean success;
|
||||
//判断用户是不是恶意刷邮箱,在规定时间内进行的
|
||||
String redisKey = RedisAuthKey.getGoogleCloseCodeKey( email);
|
||||
if (redisService.hasKey(redisKey)) {
|
||||
@@ -930,7 +912,7 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
long overTime = redisService.getExpire(redisKey);
|
||||
redisService.setCacheObject(redisKey, emailCodeValue, overTime, TimeUnit.SECONDS
|
||||
);
|
||||
success = sendEmail(email,emailCode);
|
||||
sendCloseEmail(email,emailCode);
|
||||
}
|
||||
} else {
|
||||
String emailCode = CodeUtils.creatCode(6);
|
||||
@@ -944,37 +926,22 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
redisService.setCacheObject(redisKey, emailCodeValue,
|
||||
10L, TimeUnit.MINUTES
|
||||
);
|
||||
success = sendCloseEmail(email,emailCode);
|
||||
sendCloseEmail(email,emailCode);
|
||||
}
|
||||
return success ? Result.success("发送邮箱验证码成功") : Result.fail("发送邮箱验证码失败,请稍后重试");
|
||||
return Result.success("发送邮箱验证码成功");
|
||||
}
|
||||
public boolean sendCloseEmail(String email,String code){
|
||||
String text = "M2Pool:\n" +
|
||||
"您正在关闭谷歌验证器!\n" +
|
||||
"您的邮箱验证验证码是:\n\t"+code +
|
||||
"\n此验证码10分钟有效。";
|
||||
try {
|
||||
//true 代表支持复杂的类型
|
||||
MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(javaMailSender.createMimeMessage(),true);
|
||||
//邮件发信人
|
||||
mimeMessageHelper.setFrom(sendMailer);
|
||||
//邮件收信人 1或多个
|
||||
mimeMessageHelper.setTo(email);
|
||||
//邮件主题
|
||||
mimeMessageHelper.setSubject("[M2Pool] 邮箱验证码");
|
||||
//邮件内容
|
||||
mimeMessageHelper.setText(text);
|
||||
//邮件发送时间
|
||||
mimeMessageHelper.setSentDate(new Date());
|
||||
/**
|
||||
* 关闭谷歌验证
|
||||
* @param to
|
||||
* @return
|
||||
*/
|
||||
public void sendCloseEmail(String to,String code){
|
||||
Map<String, Object> content = new HashMap<>();
|
||||
content.put("code",code);
|
||||
content.put("text","Turning off Google's two-factor authentication email verification code is valid for 10 minutes");
|
||||
EmailTemplateEntity message = new EmailTemplateEntity(to,"Turning off Google two-factor authentication, email verification code","power_leasingEmail",content);
|
||||
sendHtmlEmail(message.getEmail(),message.getSubject(),message.getTemplateName(),message.getData());
|
||||
|
||||
//发送邮件
|
||||
javaMailSender.send(mimeMessageHelper.getMimeMessage());
|
||||
//System.out.println("发送邮件成功:"+sendMailer+"->"+to);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
System.out.println("发送邮件失败:"+e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Result<String> closeStepTwo(GoogleCloseVo vo) {
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>offline notification</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" role="region" aria-label="M2POOL offline notification" tabindex="0"
|
||||
th:style="'background-image: url(' + @{${imagePrefix} + '/img/email/bg1.png'} + '); width:100%; max-width:600px; height:auto; min-height:100vh; margin:0 auto; position:relative; overflow:hidden; padding:2%; background-color:#f5f5f5; background-size:cover; background-repeat:no-repeat;box-sizing:border-box;'">
|
||||
<!-- 顶部品牌标识 -->
|
||||
<div class="brand" aria-label="M2POOL brand logo">
|
||||
<img th:src= "@{${imagePrefix} + '/img/email/logo.png'}" alt="logo" style="width:120px; height:auto; margin-left:10%; margin-top:6%;">
|
||||
</div>
|
||||
|
||||
<!-- 中心验证码卡片 -->
|
||||
<section class="card" aria-label="Offline Notification Card" th:style="'background-image: url(' + @{${imagePrefix} + '/img/email/daio.png'} + ');width:100%; max-width:310px; height:auto; min-height:240px; margin:0 auto; margin-top:10vh; box-shadow:0 8px 24px rgba(17, 24, 39, 0.10), 0 2px 6px rgba(17, 24, 39, 0.06); position:relative; overflow:hidden; padding:44px 40px 36px; text-align:center; background-color:#ffffff; background-size:105% 112%; background-position:center; background-repeat:no-repeat; border-radius:12px;'">
|
||||
<p class="notice" style="color:rgba(0,0,0,0.8); font-size:18px; margin-bottom:15px;">Your <span class="account-name" th:text="${coin}" style="color:#F94D87; font-weight:900; font-size:20px;"></span> mining account: <span class="account-name" style="color:#F94D87; font-weight:900; font-size:20px;" th:text="${user}"></span> </p>
|
||||
<p class="notice" style="color:rgba(0,0,0,0.8); font-size:18px; margin-bottom:15px;"> <span class="account-name" th:text="${offOnlineNumbers}" style="color:#F94D87; font-weight:900; font-size:20px;"></span> mining machines are offline!</p>
|
||||
<p class="notice" style="color:rgba(0,0,0,0.8); font-size:18px;">If your mining rig has been abnormally disconnected, please address it promptly!</p>
|
||||
</section>
|
||||
|
||||
<!-- 底部帮助与联系入口 -->
|
||||
<footer class="page-footer" style="margin-top:18vh; width:100%; height:auto; text-align:center;">
|
||||
<div class="divider" aria-hidden="true" style="width:100%; height:3px; background:#DDDDDD; margin:8px 0 20px;"></div>
|
||||
<p style="margin:0; padding:0; font-size:14px; color:#777777;">
|
||||
Thank you for choosing M2POOL. Need help?
|
||||
<a class="contact-link" style="color:#111827; font-weight:800; text-decoration:none; border-bottom:2px solid #111827; outline:none;" href="mailto:support@m2pool.com" aria-label="Contact Customer Service Email">Please contact customer service.</a>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
161
src/main/resources/templates/power_leasingEmail.html
Normal file
161
src/main/resources/templates/power_leasingEmail.html
Normal file
@@ -0,0 +1,161 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
||||
<title>Power Leasing - 邮箱验证码</title>
|
||||
</head>
|
||||
|
||||
<body style="margin:0; padding:0; background:#f6f7fb;">
|
||||
<div
|
||||
role="region"
|
||||
aria-label="Power Leasing 邮箱验证码页面"
|
||||
tabindex="0"
|
||||
style="
|
||||
width:100%;
|
||||
max-width:600px;
|
||||
height:auto;
|
||||
min-height:100vh;
|
||||
margin:0 auto;
|
||||
box-sizing:border-box;
|
||||
padding:6% 5%;
|
||||
position:relative;
|
||||
overflow:hidden;
|
||||
background: linear-gradient(180deg, #ffffff 0%, #f3f6ff 55%, #f6f7fb 100%);
|
||||
"
|
||||
>
|
||||
<section
|
||||
aria-label="验证码卡片"
|
||||
style="
|
||||
box-sizing:border-box;
|
||||
width:92%;
|
||||
max-width:360px;
|
||||
height:auto;
|
||||
min-height:260px;
|
||||
margin:0 auto;
|
||||
margin-top:10vh;
|
||||
box-shadow:0 8px 24px rgba(17, 24, 39, 0.10);
|
||||
position:relative;
|
||||
overflow:hidden;
|
||||
display:block;
|
||||
text-align:center;
|
||||
border-radius:14px;
|
||||
padding:24px 20px 22px;
|
||||
background:#ffffff;
|
||||
"
|
||||
>
|
||||
<p
|
||||
style="
|
||||
margin: 10% 0 0 0;
|
||||
padding: 0;
|
||||
color: rgba(0,0,0,0.72);
|
||||
font-size: 16px;
|
||||
line-height: 1.5;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
|
||||
text-align: center;
|
||||
"
|
||||
th:text="${text}"
|
||||
>
|
||||
</p>
|
||||
|
||||
<div
|
||||
role="group"
|
||||
aria-live="polite"
|
||||
aria-label="验证码"
|
||||
style="
|
||||
position:relative;
|
||||
margin: 16px auto 0;
|
||||
display:block;
|
||||
width: 86%;
|
||||
max-width: 300px;
|
||||
height: auto;
|
||||
padding: 12px 0;
|
||||
border-radius: 12px;
|
||||
background: #ffffff;
|
||||
border: 3px solid #651EFE;
|
||||
box-sizing: border-box;
|
||||
text-align:center;
|
||||
"
|
||||
>
|
||||
<span
|
||||
data-default-code="4MKM6AX"
|
||||
aria-label="验证码内容"
|
||||
tabindex="0"
|
||||
style="
|
||||
display: block;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
|
||||
font-weight: 800;
|
||||
font-size: 24px;
|
||||
letter-spacing: 0.18em;
|
||||
color: #111827;
|
||||
line-height: 1;
|
||||
"
|
||||
th:text="${code}"
|
||||
>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<p
|
||||
style="
|
||||
margin: 14px 0 0 0;
|
||||
padding: 0;
|
||||
color: rgba(0,0,0,0.45);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
|
||||
"
|
||||
>
|
||||
如果这不是你的操作,请忽略本邮件。
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<footer
|
||||
aria-label="页脚帮助信息"
|
||||
style="
|
||||
margin-top: 18vh;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
text-align: center;
|
||||
"
|
||||
>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
style="
|
||||
width: 100%;
|
||||
height: 3px;
|
||||
background: #dddddd;
|
||||
margin: 8px 0 18px;
|
||||
"
|
||||
></div>
|
||||
<p
|
||||
style="
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 14px;
|
||||
color: #6b7280;
|
||||
line-height: 1.6;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
|
||||
"
|
||||
>
|
||||
感谢您选择 Power Leasing。如需帮助,
|
||||
<a
|
||||
href="mailto:support@m2pool.com"
|
||||
aria-label="联系客服邮箱"
|
||||
tabindex="0"
|
||||
style="
|
||||
color: #111827;
|
||||
font-weight: 800;
|
||||
text-decoration: none;
|
||||
border-bottom: 2px solid #111827;
|
||||
outline: none;
|
||||
"
|
||||
>
|
||||
请联系客户服务
|
||||
</a>
|
||||
。
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user