提交 0052e55f 作者: 洪东保

发送邮件带一个跳转到会议详情页面的链接

父级 5ef1fb26
package com.cmeeting.ad.controller;
import com.alibaba.fastjson.JSONObject;
import com.cmeeting.ad.service.UserService;
import com.cmeeting.ad.vo.UserVo;
import com.cmeeting.annotation.OperLog;
import com.cmeeting.constant.RecordTemplateConstant;
import com.cmeeting.util.AESUtils;
import com.cmeeting.util.IPUtils;
import com.cmeeting.util.R;
import com.cmeeting.ad.vo.ApplicationUserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -19,6 +22,8 @@ public class UserController {
@Autowired
private UserService userService;
@Value("${aec.key}")
private String aseKey;
/**
* 账号密码登录
......@@ -61,7 +66,9 @@ public class UserController {
}
@PostMapping(value = "/emailAuth")
public R emailAuth(@Validated @RequestBody UserVo.Auth vo) {
return R.ok(userService.emailAuth(vo));
public R emailAuth(@Validated @RequestBody UserVo.LoginDecrypt vo) {
String decrypt = AESUtils.decrypt(vo.getData(), aseKey);
UserVo.Auth auth = JSONObject.parseObject(decrypt, UserVo.Auth.class);
return R.ok(userService.emailAuth(auth));
}
}
\ No newline at end of file
......@@ -152,6 +152,7 @@ public class UserServiceImpl implements UserService {
HashMap<String, String> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("userId", userId);
stringStringHashMap.put("tenantId", permissionTenantId);
stringStringHashMap.put("role", RecordTemplateConstant.TEMPLATE_TYPE_CUSTOM);
stringStringHashMap.put("nick", nick);
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(userId, permissionTenantId);
usernamePasswordAuthenticationToken.setDetails(stringStringHashMap);
......
package com.cmeeting.email;
import cn.hutool.json.JSONUtil;
import com.azure.core.credential.AccessToken;
import com.azure.core.credential.TokenRequestContext;
import com.azure.identity.ClientSecretCredential;
......@@ -11,6 +12,7 @@ import com.cmeeting.exception.RobotBaseException;
import com.cmeeting.log.service.ProcessLogService;
import com.cmeeting.pojo.MeetEmailTemplate;
import com.cmeeting.service.MeetEmailTemplateService;
import com.cmeeting.util.AESUtils;
import com.cmeeting.util.RSAUtils;
import com.cmeeting.util.RedisUtils;
import com.cmeeting.vo.EmailPush;
......@@ -36,6 +38,8 @@ import javax.mail.internet.*;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.MessageFormat;
......@@ -61,7 +65,8 @@ public class EmailSender {
private String clientSecret;
@Value("${email.microsoft.tenantId}")
private String tenantId;
@Value("${aec.key}")
private String aseKey;
@Resource
private ProcessLogService processLogService;
@Resource
......@@ -90,6 +95,7 @@ public class EmailSender {
String subMeetingId = emailPushBuilder.getSubMeetingId();
Integer meetingInstanceId = emailPushBuilder.getMeetingInstanceId();
String toUserCode = emailPushBuilder.getToUserCode();
String toUser = emailPushBuilder.getToUser();
Boolean emailPushAccess = emailPushBuilder.getEmailPushAccess();
//用户自定义邮件推送许可
if (emailPushAccess) {
......@@ -142,8 +148,16 @@ public class EmailSender {
.orderByDesc(MeetEmailTemplate::getCreateTime)
.select(MeetEmailTemplate::getContent).last("limit 1"));
String emailContentTemplate = one.getContent();
long expireTimestamp = ZonedDateTime.now().plusDays(2).toInstant().toEpochMilli();
body.content = MessageFormat.format(emailContentTemplate, meetingInstanceId, toUserCode, String.valueOf(expireTimestamp));
long expireTimestamp = ZonedDateTime.now().plusDays(1).toInstant().toEpochMilli();
UserVo.Auth auth = new UserVo.Auth();
auth.setId(toUserCode);
auth.setNick(toUser);
auth.setExpireDate(expireTimestamp);
String s = JSONUtil.toJsonStr(auth);
String encrypt = AESUtils.encrypt(s, aseKey);
body.content = MessageFormat.format(emailContentTemplate, URLEncoder.encode(encrypt, StandardCharsets.UTF_8.name()), String.valueOf(meetingInstanceId));
message.body = body;
LinkedList<Recipient> toRecipientsList = new LinkedList<>();
......
......@@ -3,6 +3,8 @@ package com.cmeeting.util;
//import com.google.api.client.repackaged.org.apache.commons.codec.binary.Base64;
import cn.hutool.core.codec.Base64;
import cn.hutool.json.JSONUtil;
import com.cmeeting.ad.vo.UserVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
......@@ -12,10 +14,13 @@ import javax.crypto.IllegalBlockSizeException;
import javax.crypto.spec.SecretKeySpec;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.InvalidKeyException;
import java.text.MessageFormat;
import java.time.ZonedDateTime;
@Slf4j
public class AESUtils {
......@@ -121,17 +126,26 @@ public class AESUtils {
}
public static void main(String[] args) throws Exception {
String filePath = "D:/desktop/a.txt";
try {
byte[] bytes = Files.readAllBytes(Paths.get(filePath));
String longStr = new String(bytes, StandardCharsets.UTF_8);
String miwen = decrypt(longStr,"biaopin123456789");// 加密
System.out.println(miwen);
} catch (Exception e) {
e.printStackTrace();
}
// String filePath = "D:/desktop/a.txt";
// try {
// byte[] bytes = Files.readAllBytes(Paths.get(filePath));
// String longStr = new String(bytes, StandardCharsets.UTF_8);
// String miwen = decrypt(longStr,"");// 加密
// System.out.println(miwen);
// } catch (Exception e) {
// e.printStackTrace();
// }
UserVo.Auth auth = new UserVo.Auth();
auth.setId("00015545");
auth.setNick("李");
long expireTimestamp = ZonedDateTime.now().plusDays(2).toInstant().toEpochMilli();
auth.setExpireDate(expireTimestamp);
String s = JSONUtil.toJsonStr(auth);
String encrypt = AESUtils.encrypt(s, "biaopin123456789");
System.out.println(encrypt);
String url = "https://chatbottest.cimc.com:5277/login?token={0}&source=email";
System.out.println(MessageFormat.format(url, URLEncoder.encode(encrypt)));
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论