|
@@ -5,6 +5,7 @@ import com.jeesite.common.config.Global;
|
|
|
import com.jeesite.common.constant.Constants;
|
|
|
import com.jeesite.common.idgen.IdGen;
|
|
|
import com.jeesite.common.image.CaptchaUtils;
|
|
|
+import com.jeesite.common.lang.DateUtils;
|
|
|
import com.jeesite.common.lang.StringUtils;
|
|
|
import com.jeesite.common.msg.EmailUtils;
|
|
|
import com.jeesite.modules.bjflapi.AbstractController;
|
|
@@ -17,7 +18,6 @@ import com.jeesite.modules.report.util.oConvertUtils;
|
|
|
import com.jeesite.modules.sys.annotation.WebsiteAuth;
|
|
|
import com.jeesite.modules.sys.utils.R;
|
|
|
import com.jeesite.modules.sys.utils.RedisUtil;
|
|
|
-import com.jeesite.modules.sys.utils.UserUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -47,9 +47,10 @@ public class WebsiteUserControllerApi extends AbstractController {
|
|
|
private int EXPIRE;
|
|
|
|
|
|
@GetMapping(value = "getValidCode")
|
|
|
- public String getValidCode(HttpServletResponse response) throws Exception {
|
|
|
+ public String getValidCode(String unTime, HttpServletResponse response) throws Exception {
|
|
|
String s = CaptchaUtils.generateCaptcha(response.getOutputStream());
|
|
|
- UserUtils.putCache(Constants.WEBSITE_VALID_CODE, s);
|
|
|
+ redisUtil.set(Constants.WEBSITE_VALID_CODE + unTime, s);
|
|
|
+ redisUtil.expire(Constants.WEBSITE_VALID_CODE + unTime, 120);
|
|
|
return s;
|
|
|
}
|
|
|
|
|
@@ -72,10 +73,10 @@ public class WebsiteUserControllerApi extends AbstractController {
|
|
|
password = DesUtils.decode(password, secretKey);
|
|
|
if (StringUtils.isNotEmpty(websiteUser.getValidCode())) {
|
|
|
//验证是否一致
|
|
|
- if (!websiteUser.getValidCode().equals(UserUtils.getCache(Constants.WEBSITE_VALID_CODE))) {
|
|
|
+ if (!websiteUser.getValidCode().equals((String) redisUtil.get(Constants.WEBSITE_VALID_CODE + websiteUser.getUnTime()))) {
|
|
|
return R.error("验证码不一致");
|
|
|
}
|
|
|
- UserUtils.removeCache(Constants.WEBSITE_VALID_CODE);
|
|
|
+ redisUtil.del(Constants.WEBSITE_VALID_CODE + websiteUser.getUnTime());
|
|
|
}
|
|
|
//查询用户
|
|
|
WebsiteUser oldUser = websiteUserService.findLoginCode(loginCode);
|
|
@@ -207,13 +208,14 @@ public class WebsiteUserControllerApi extends AbstractController {
|
|
|
if (websiteUser == null) {
|
|
|
return R.error("邮箱不存在");
|
|
|
}
|
|
|
- String dateKey = "wuLastDate";
|
|
|
+ String dateKey = "wuLastDate" + email;
|
|
|
// 操作是否频繁验证, 如果离上次获取验证码小于60秒,则提示操作频繁。
|
|
|
- Date date = UserUtils.getCache(dateKey);
|
|
|
- if (date != null && (System.currentTimeMillis()-date.getTime())/(1000L) < 60L){
|
|
|
+ String date = (String) redisUtil.get(dateKey);
|
|
|
+ if (date != null && (System.currentTimeMillis()- DateUtils.parseDate(date).getTime())/(1000L) < 60L){
|
|
|
return R.error("您当前操作太频繁,请稍等一会再操作!");
|
|
|
}else{
|
|
|
- UserUtils.putCache(dateKey, new Date());
|
|
|
+ redisUtil.set(dateKey, new Date());
|
|
|
+ redisUtil.expire(dateKey, 60);
|
|
|
}
|
|
|
String uuid = IdGen.uuid();
|
|
|
// 设置token缓存有效时间
|