// System.out.println(findType);
FindPswdStat findPswdStat = (FindPswdStat) WebHelper.getSessionAttribute(null, Constant.SESSION_FIND_PSWD_STAT);
if (findPswdStat != null || findPswdStat != FindPswdStat.FINISHED) {
// 运行步骤出错了;
}
User user = accountInfoService.getAccountInfoByEmail(email);
if (user == null) {
// 用户不存在
mav.setViewName(ViewPaths.USER_FINDPSWDREQUEST);
mav.addObject("errorMessage", "你所输入的用户不存在。");
} else {
WebHelper.setSessionAttribute(null, Constant.SESSION_FIND_PSWD_USER, user);
// 用户请求通过安全email来找回密码
if (findType == 0) {
String toSendEmail = null;
if (user.getSecurityEmail() != null) {
toSendEmail = user.getSecurityEmail();
mav.addObject("message", "成功发送到您的安全E-mail(" + toSendEmail + ")。");
} else {
toSendEmail = email;
mav.addObject("message", "成功发送到您的E-mail(" + toSendEmail + ")。");
}
mav.addObject("email", email);
EmailToken token = emailTokenService.addToken(user.getId(), email, EmailTokenType.PASSWORD_FIND);
String emailTitle = FreeMarkerUtils.getForgetPasswordMailTitle(email);
String emailContent = FreeMarkerUtils.getForgetPasswordMailContent(email, token.getToken());
// emailTitle,emailContent输出已经测试过了
MailUtils.sendHtmlMail(toSendEmail, emailTitle, emailContent);
WebHelper.setSessionAttribute(null, Constant.SESSION_FIND_PSWD_STAT, FindPswdStat.FINISHED);
mav.setViewName(ViewPaths.USER_FINDPSWDBYEMAIL);
}
// 通过回答问题来找回密码
else if (findType == 1) {
String securityQuestion = user.getSecurityQuestion();
if (securityQuestion != null) {
mav.addObject("securityQuestion", securityQuestion);
WebHelper.setSessionAttribute(null, Constant.SESSION_FIND_PSWD_STAT, FindPswdStat.REQUEST_TO_ANSWER_QUESTION);
WebHelper.setSessionAttribute(null, Constant.SESSION_FIND_PSWD_QUESTION_ANSWERED, 0);
} else {