소스 검색

获取登录验证码唯一

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){