Commit d2a9f666 by WeiCong

优化验证码失效策略

parent 84a7c0d7
......@@ -60,6 +60,7 @@ public class LoginController {
map.put("j_dncode", dncode);
map.put("j_sendcode", sendcode);
map.put("j_verifycode", verifycode);
RedisUtil.delete(kb);
context = NoUiContextManager.createNoUiContext(noUiRequest);
if (context.getSession().login(map)) {
......
......@@ -30,6 +30,7 @@ public class VerifyCodeCreateController {
private static final Log log = LogFactory.getLog(VerifyCodeCreateController.class);
private static final int width = 100;//验证码图片宽度
private static final int height = 50;//验证码图片高度
private static final int vcsessionout = 120;//验证码超时时间
@Autowired
private NoUiVersion noUiVersion;
......@@ -73,7 +74,7 @@ public class VerifyCodeCreateController {
}
String kb=key.toString().toLowerCase();
log.info("key==="+kb);
RedisUtil.set(kb, codes.toString());
RedisUtil.set(kb, codes.toString(),vcsessionout);
// request.getSession().setAttribute(Constants.VERIFYCODE, codes.toString());
ImageIO.write(bi, "JPG", response.getOutputStream());
......
......@@ -87,6 +87,10 @@ public class RedisUtil {
}
public static void set(String key, Object value) throws Exception {
set(key,value,sessionTimeOut);
}
public static void set(String key, Object value,int sessionTimeOut) throws Exception {
checkRedisNodeAvailable();
getRedisConnection().opsForValue().set(key, value);
......
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