feat: 【bug-108】给代理配置的账号超出72小时没激活就没办法激活了,需要增加重发激活邮件的功能

用户端和管理端都加上
This commit is contained in:
曹鹏飞 2025-04-28 10:37:40 +08:00
parent 64ed311191
commit a5ef6c9bc6
2 changed files with 46 additions and 18 deletions

View File

@ -386,14 +386,28 @@ public class AppUserController extends ControllerBase {
public ApiResult<Void> sendResetPasswordEmail(@Valid @RequestBody @NotEmpty List<Integer> ids){
try {
for (Integer id : ids) {
String password=RandomUtil.randomString(6);
AppUser appUser=appUserService.resetPassword(id,password);
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD, appUser.getLanguageCode());
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_RESET_PASSWORD_NOTIFY, appUser.getLanguageCode())
.replace("${loginName}",appUser.getLoginName())
.replace("${url}",activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString((appUser.getEmail()+"|0").getBytes()))
.replace("${password}",password);
emailService.sendEmail(appUser.getEmail(), subject, content);
AppUser appUser = appUserService.getById(id);
if (Objects.nonNull(appUser)) {
if (Objects.equals(appUser.getState().intValue(), 1)) {
String password = RandomUtil.randomString(6);
appUserService.resetPassword(id, password);
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD, appUser.getLanguageCode());
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_RESET_PASSWORD_NOTIFY, appUser.getLanguageCode())
.replace("${loginName}", appUser.getLoginName())
.replace("${url}", activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString((appUser.getEmail() + "|0").getBytes()))
.replace("${password}", password);
emailService.sendEmail(appUser.getEmail(), subject, content);
} else if(Objects.equals(appUser.getState().intValue(), 0)){
String password = RandomUtil.randomString(6);
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_ACTIVATION, appUser.getLanguageCode());
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_ACCOUNT_ACTIVATION_NOTIFY, appUser.getLanguageCode())
.replace("${loginName}", appUser.getEmail())
.replace("${url}", activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString((appUser.getEmail() + "|0").getBytes()))
.replace("${password}", password)
.replace("${website}", websiteUrl);
emailService.sendEmail(appUser.getEmail(), subject, content);
}
}
}
}catch (Exception ex){
throw new NflgException(STATE.BusinessError,"发送邮件失败:"+ex.getMessage());

View File

@ -291,7 +291,7 @@ public class UserController extends ControllerBase {
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD, appUser.getLanguageCode());
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_RESET_PASSWORD_NOTIFY, appUser.getLanguageCode())
.replace("${loginName}",appUser.getLoginName())
.replace("${url}",activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString(email.getBytes()))
.replace("${url}",activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString((email+"|0").getBytes()))
.replace("${password}",password);
emailService.sendEmail(email, subject,content);
} catch (Exception ex) {
@ -310,15 +310,29 @@ public class UserController extends ControllerBase {
public ApiResult<Void> sendResetPasswordEmail(@Valid @RequestBody @NotEmpty List<Integer> ids){
try {
for (Integer id : ids) {
String password=RandomUtil.randomString(6);
AppUser appUser=appUserService.resetPassword(id,password);
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD, appUser.getLanguageCode());
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_RESET_PASSWORD_NOTIFY, appUser.getLanguageCode())
.replace("${loginName}",appUser.getLoginName())
.replace("${url}",activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString(appUser.getEmail().getBytes()))
.replace("${password}",password)
.replace("${website}",websiteUrl);
emailService.sendEmail(appUser.getEmail(), subject, content);
AppUser appUser = appUserService.getById(id);
if (Objects.nonNull(appUser)) {
if (Objects.equals(appUser.getState().intValue(), 1)) {
String password = RandomUtil.randomString(6);
appUserService.resetPassword(id, password);
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_RESET_PASSWORD, appUser.getLanguageCode());
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_RESET_PASSWORD_NOTIFY, appUser.getLanguageCode())
.replace("${loginName}", appUser.getLoginName())
.replace("${url}", activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString((appUser.getEmail()+"|0").getBytes()))
.replace("${password}", password)
.replace("${website}", websiteUrl);
emailService.sendEmail(appUser.getEmail(), subject, content);
} else if(Objects.equals(appUser.getState().intValue(), 0)){
String password = RandomUtil.randomString(6);
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_ACCOUNT_ACTIVATION, appUser.getLanguageCode());
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_ACCOUNT_ACTIVATION_NOTIFY, appUser.getLanguageCode())
.replace("${loginName}", appUser.getEmail())
.replace("${url}", activateUrl + "?code=" + Base64.getUrlEncoder().encodeToString((appUser.getEmail() + "|0").getBytes()))
.replace("${password}", password)
.replace("${website}", websiteUrl);
emailService.sendEmail(appUser.getEmail(), subject, content);
}
}
}
}catch (Exception ex){
throw new NflgException(STATE.BusinessError,"发送邮件失败:"+ex.getMessage());