Forráskód Böngészése

获取登录验证码唯一

lyhzzz 2 éve
szülő
commit
b97ecc1848

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