实名认证--聚合实名认证--修改验证短信验证码逻辑
This commit is contained in:
parent
6a8ee8578b
commit
7dae675586
@ -519,7 +519,9 @@ public class AppSystemController extends BaseController {
|
||||
String code = juheAuthenticationDto.getCode();
|
||||
|
||||
String username = SecurityUtils.getUsername();
|
||||
appvalidateCaptcha(username, code, mobile);
|
||||
|
||||
// 验证短信验证码
|
||||
appvalidateCaptchaJuhe(username, code, mobile);
|
||||
|
||||
Long userId = getUserId();
|
||||
UserInfo userInfo = userInfoService.selectUserInfoByUserId(userId);
|
||||
@ -542,6 +544,13 @@ public class AppSystemController extends BaseController {
|
||||
userInfo.setIdCard(idcard);
|
||||
userInfoService.updateUserInfo(userInfo);
|
||||
|
||||
// 删除缓存
|
||||
// 缓存的验证码和试错次数
|
||||
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + mobile;
|
||||
String countKey = CacheConstants.CAPTCHA_CODE_KEY_COUNT + mobile;
|
||||
redisCache.deleteObject(verifyKey);
|
||||
redisCache.deleteObject(countKey);
|
||||
|
||||
return success("实名认证成功");
|
||||
}
|
||||
|
||||
@ -2466,6 +2475,50 @@ public class AppSystemController extends BaseController {
|
||||
|
||||
}
|
||||
|
||||
private void appvalidateCaptchaJuhe(String username, String code, String phone) {
|
||||
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
||||
if (captchaEnabled) {
|
||||
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + phone;
|
||||
String captcha = redisCache.getCacheObject(verifyKey);
|
||||
|
||||
// 尝试次数
|
||||
String countKey = CacheConstants.CAPTCHA_CODE_KEY_COUNT + phone;
|
||||
int captchaCount = redisCache.getCacheObject(countKey);
|
||||
|
||||
if (captcha == null ) {
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
|
||||
throw new CaptchaDisableException();
|
||||
}
|
||||
|
||||
if(captchaCount >= 3){
|
||||
// 删除缓存
|
||||
redisCache.deleteObject(verifyKey);
|
||||
redisCache.deleteObject(countKey);
|
||||
|
||||
// 验证码失效
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
|
||||
throw new CaptchaDisableException();
|
||||
}
|
||||
|
||||
|
||||
if (!code.equalsIgnoreCase(captcha))
|
||||
{
|
||||
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
|
||||
throw new CaptchaException();
|
||||
}
|
||||
// 尝试次数加1
|
||||
redisCache.setCacheObject(countKey, captchaCount + 1);
|
||||
// else{
|
||||
// // 登录成功删除验证码
|
||||
// redisCache.deleteObject(verifyKey);
|
||||
// redisCache.deleteObject(countKey);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user