mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-30 09:48:43 +08:00 
			
		
		
		
	AJ-Captcha 增加验证码二次校验
This commit is contained in:
		| @@ -33,6 +33,10 @@ public class AuthLoginReqVO { | |||||||
|     @Length(min = 4, max = 16, message = "密码长度为 4-16 位") |     @Length(min = 4, max = 16, message = "密码长度为 4-16 位") | ||||||
|     private String password; |     private String password; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "验证码", required = true, example = "PfcH6mgr8tpXuMWFjvW6YVaqrswIuwmWI5dsVZSg7sGpWtDCUbHuDEXl3cFB1+VvCC/rAkSwK8Fad52FSuncVg==") | ||||||
|  |     @NotEmpty(message = "验证码不能为空") | ||||||
|  |     private String captchaVerification; | ||||||
|  |  | ||||||
|     // ========== 绑定社交登录时,需要传递如下参数 ========== |     // ========== 绑定社交登录时,需要传递如下参数 ========== | ||||||
|  |  | ||||||
|     @ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 SysUserSocialTypeEnum 枚举值") |     @ApiModelProperty(value = "社交平台的类型", required = true, example = "10", notes = "参见 SysUserSocialTypeEnum 枚举值") | ||||||
|   | |||||||
| @@ -21,6 +21,9 @@ import cn.iocoder.yudao.module.system.service.member.MemberService; | |||||||
| import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; | import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; | ||||||
| import cn.iocoder.yudao.module.system.service.social.SocialUserService; | import cn.iocoder.yudao.module.system.service.social.SocialUserService; | ||||||
| import cn.iocoder.yudao.module.system.service.user.AdminUserService; | import cn.iocoder.yudao.module.system.service.user.AdminUserService; | ||||||
|  | import com.anji.captcha.model.common.ResponseModel; | ||||||
|  | import com.anji.captcha.model.vo.CaptchaVO; | ||||||
|  | import com.anji.captcha.service.CaptchaService; | ||||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
|  |  | ||||||
| @@ -51,10 +54,10 @@ public class AdminAuthServiceImpl implements AdminAuthService { | |||||||
|     private SocialUserService socialUserService; |     private SocialUserService socialUserService; | ||||||
|     @Resource |     @Resource | ||||||
|     private MemberService memberService; |     private MemberService memberService; | ||||||
|  |  | ||||||
|     @Resource |     @Resource | ||||||
|     private Validator validator; |     private Validator validator; | ||||||
|  |     @Resource | ||||||
|  |     private CaptchaService captchaService; | ||||||
|     @Resource |     @Resource | ||||||
|     private SmsCodeApi smsCodeApi; |     private SmsCodeApi smsCodeApi; | ||||||
|  |  | ||||||
| @@ -81,6 +84,10 @@ public class AdminAuthServiceImpl implements AdminAuthService { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public AuthLoginRespVO login(AuthLoginReqVO reqVO) { |     public AuthLoginRespVO login(AuthLoginReqVO reqVO) { | ||||||
|  |         CaptchaVO captchaVO = new CaptchaVO(); | ||||||
|  |         captchaVO.setCaptchaVerification(reqVO.getCaptchaVerification()); | ||||||
|  |         ResponseModel response = captchaService.verification(captchaVO); | ||||||
|  |         if(response.isSuccess()){ | ||||||
|             // 使用账号密码,进行登录 |             // 使用账号密码,进行登录 | ||||||
|             AdminUserDO user = authenticate(reqVO.getUsername(), reqVO.getPassword()); |             AdminUserDO user = authenticate(reqVO.getUsername(), reqVO.getPassword()); | ||||||
|  |  | ||||||
| @@ -91,6 +98,9 @@ public class AdminAuthServiceImpl implements AdminAuthService { | |||||||
|             } |             } | ||||||
|             // 创建 Token 令牌,记录登录日志 |             // 创建 Token 令牌,记录登录日志 | ||||||
|             return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME); |             return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME); | ||||||
|  |         }else{ | ||||||
|  |             throw exception(AUTH_LOGIN_CAPTCHA_CODE_ERROR); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 xingyu
					xingyu