From 036cc1ac25a8e0bc80601b894f72334726c472f2 Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Thu, 23 Jun 2022 14:02:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AE=9E=E7=8E=B0=E9=AA=8C=E8=AF=81=E7=A0=81?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cnbm/admin/service/impl/LoginServiceImpl.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ym-admin/src/main/java/com/cnbm/admin/service/impl/LoginServiceImpl.java b/ym-admin/src/main/java/com/cnbm/admin/service/impl/LoginServiceImpl.java index 1c8fdbb..ada95af 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/service/impl/LoginServiceImpl.java +++ b/ym-admin/src/main/java/com/cnbm/admin/service/impl/LoginServiceImpl.java @@ -2,9 +2,11 @@ package com.cnbm.admin.service.impl; import com.cnbm.admin.entity.LoginUser; import com.cnbm.admin.params.LoginParam; +import com.cnbm.admin.service.CaptchaService; import com.cnbm.admin.utils.JwtUtil; import com.cnbm.admin.service.LoginService; import com.cnbm.admin.utils.ResponseResult; +import com.cnbm.common.exception.ErrorCode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.security.authentication.AuthenticationManager; @@ -32,8 +34,16 @@ public class LoginServiceImpl implements LoginService { @Autowired private AuthenticationManager authenticationManager; + @Autowired + private CaptchaService captchaService; + @Override public ResponseResult login(HttpServletRequest request, LoginParam loginParam) { + //验证码是否正确 + boolean flag = captchaService.validate(loginParam.getUuid(), loginParam.getCaptcha()); + if(!flag){ + return new ResponseResult(ErrorCode.CAPTCHA_ERROR,"验证码错误"); + } UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginParam.getUsername(),loginParam.getPassword()); Authentication authenticate = authenticationManager.authenticate(authenticationToken); if (Objects.isNull(authenticate)) {