From 708e10d0a3ffcbf43ae6fd58645e066f870409f8 Mon Sep 17 00:00:00 2001 From: Parker Date: Tue, 5 Jan 2021 21:20:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/login/web/LoginRestController.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/login/web/LoginRestController.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/login/web/LoginRestController.java index f2bded77..1061aa63 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/login/web/LoginRestController.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/login/web/LoginRestController.java @@ -25,9 +25,11 @@ import org.opsli.api.wrapper.system.tenant.TenantModel; import org.opsli.api.wrapper.system.user.UserModel; import org.opsli.common.annotation.limiter.Limiter; import org.opsli.common.api.TokenThreadLocal; +import org.opsli.common.enums.AlertType; import org.opsli.common.exception.TokenException; import org.opsli.common.thread.refuse.AsyncProcessQueueReFuse; import org.opsli.common.utils.IPUtil; +import org.opsli.common.utils.OutputStreamUtil; import org.opsli.core.msg.TokenMsg; import org.opsli.core.security.shiro.realm.JwtRealm; import org.opsli.core.utils.CaptchaUtil; @@ -172,19 +174,23 @@ public class LoginRestController { /** * 验证码 */ - @Limiter + @Limiter(alertType = AlertType.ALERT) @ApiOperation(value = "验证码", notes = "验证码") @GetMapping("captcha.jpg") public void captcha(String uuid, HttpServletResponse response) throws IOException { response.setHeader("Cache-Control", "no-store, no-cache"); response.setContentType("image/jpeg"); - //获取图片验证码 - BufferedImage image = CaptchaUtil.getCaptcha(uuid); - if(image != null){ - ServletOutputStream out = response.getOutputStream(); - ImageIO.write(image, "jpg", out); - IOUtils.closeQuietly(out); + try { + //获取图片验证码 + BufferedImage image = CaptchaUtil.getCaptcha(uuid); + if(image != null){ + ServletOutputStream out = response.getOutputStream(); + ImageIO.write(image, "jpg", out); + IOUtils.closeQuietly(out); + } + }catch (RuntimeException e){ + OutputStreamUtil.exceptionResponse(e.getMessage(), response); } }