浏览代码

获取登录验证码唯一

lyhzzz 2 年之前
父节点
当前提交
b97ecc1848
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      src/main/java/com/fdkankan/fusion/controller/NoLoginController.java

+ 4 - 2
src/main/java/com/fdkankan/fusion/controller/NoLoginController.java

@@ -31,8 +31,10 @@ public class NoLoginController {
 
         try {
             LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100,4,60);
-            String code = lineCaptcha.getCode();
-            redisUtil.set(String.format(RedisKeyUtil.loginAuthCode,code),code,60);
+            while (redisUtil.hasKey(String.format(RedisKeyUtil.loginAuthCode,lineCaptcha.getCode()))){
+                lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100,4,60);
+            }
+            redisUtil.set(String.format(RedisKeyUtil.loginAuthCode,lineCaptcha.getCode()),lineCaptcha.getCode(),30);
             lineCaptcha.write(response.getOutputStream());
             response.getOutputStream().close();
         } catch (Exception e){