Commit 84a7c0d7 by WeiCong

优化集群模式后台验证码唯一标志策略

parent 43816448
......@@ -4,10 +4,7 @@ import log.Log;
import log.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import org.sss.common.model.ILoginContext;
import org.sss.common.model.IMenuItem;
import org.sss.presentation.noui.api.model.Menu;
......@@ -50,7 +47,13 @@ public class LoginController {
String dncode = noUiRequest.getDataMap().get(Constants.DNCODE) == null ? null : noUiRequest.getDataMap().get(Constants.DNCODE).toString();
String sendcode = noUiRequest.getDataMap().get(Constants.SENDCODE) == null ? null : noUiRequest.getDataMap().get(Constants.SENDCODE).toString();
// String verifycode = request.getSession().getAttribute(Constants.VERIFYCODE)==null?null:request.getSession().getAttribute(Constants.VERIFYCODE).toString();
Object verifycodeobj = RedisUtil.get(request.getRequestedSessionId());
StringBuilder key=new StringBuilder(sendcode);
if(!StringUtil.isEmpty(request.getRemoteAddr())){
key.append(request.getRemoteAddr());
}
String kb=key.toString().toLowerCase();
log.info("key==="+kb);
Object verifycodeobj = RedisUtil.get(kb);
String verifycode = verifycodeobj == null ? null : verifycodeobj.toString();
map.put("j_username", userId);
map.put("j_password", password);
......
......@@ -12,6 +12,7 @@ import org.sss.presentation.noui.api.response.NoUiVersion;
import org.sss.presentation.noui.api.response.ResultUtil;
import org.sss.presentation.noui.util.NoUiUtils;
import org.sss.presentation.noui.util.RedisUtil;
import org.sss.presentation.noui.util.StringUtil;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
......@@ -66,7 +67,13 @@ public class VerifyCodeCreateController {
g.drawString(code, (i * 18) + 10, 30);
codes.append(code);
}
RedisUtil.set(request.getRequestedSessionId(), codes.toString());
StringBuilder key=new StringBuilder(codes);
if(!StringUtil.isEmpty(request.getRemoteAddr())){
key.append(request.getRemoteAddr());
}
String kb=key.toString().toLowerCase();
log.info("key==="+kb);
RedisUtil.set(kb, codes.toString());
// request.getSession().setAttribute(Constants.VERIFYCODE, codes.toString());
ImageIO.write(bi, "JPG", response.getOutputStream());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment