提交 f5a75439 编写于 作者: rushui.chen's avatar rushui.chen

20200113 验证码删除逻辑的处理

上级 ad6a1f8b
流水线 #20717 已失败 于阶段
in 0 second
......@@ -196,6 +196,24 @@ public class Test {
changeMobileEntity.setContent(changeMobileContent);
System.out.println(JSONObject.toJSONString(changeMobileEntity));
System.out.println("---------------------------------------------------------------");
BaseRequest changeMobileu = new BaseRequest();
changeMobileu.setMobile("13024112588");
changeMobileu.setAuthCode("871756");
changeMobileu.setUnionId("o3EP_wNH2g4FGcUNByXJIbQyUVPI");
changeMobileu.setFlag(2);
String string1u= JSONObject.toJSONString(changeMobileu);
System.out.println(string1u);
String changeMobileContentu = AESUtil.aesEncrypt(string1u, "YCPQPx4qpQjEjDea");
String changeMobileKeyu = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey);
EncryptEntity changeMobileEntityu = new EncryptEntity();
changeMobileEntityu.setKey(changeMobileKeyu);
changeMobileEntityu.setContent(changeMobileContentu);
System.out.println(JSONObject.toJSONString(changeMobileEntityu));
}
......
......@@ -151,8 +151,11 @@ public class AutoCodeController extends AccountBaseController {
String message = "您的验证码是" + authCode + ",在10分钟内有效。如非本人操作,请忽略本短信!";
Integer accountIdByMobilePhone = accountService.getAccountIdByMobilePhone(mobilePhone);
long senderId = accountIdByMobilePhone == null ? 0L : accountIdByMobilePhone;
cacheClient.set(this.getAuthCodeKey(mobilePhone, flag.toString()), authCode, 600);
logger.info("验证码缓存信息----->:"+this.getAuthCodeKey(mobilePhone, flag.toString()));
String authCodeKey = getAuthCodeKey(mobilePhone, flag.toString());
boolean set = cacheClient.set(authCodeKey, authCode, 600);
logger.info(cacheClient.get(authCodeKey));
logger.info("验证码缓存是否成功----->:"+set);
logger.info("验证码缓存信息----->:"+authCodeKey);
cacheClient.set(authCodeKeySecure, System.currentTimeMillis(), 60);
//处理验证码原子性的问题
cacheClient.set(RegisterCodeKeyUtils.getRegisterKey(mobilePhone,authCode), 100, 600);
......@@ -170,4 +173,15 @@ public class AutoCodeController extends AccountBaseController {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "请输入正确的手机号");
}
}
@ApiOperation("微信获取验证码")
@PostMapping(value = "/authCode/get")
public PicaResponse getAuthCode(){
String cacheCode = cacheClient.get("authCode-2-j1VrU5MSc1uuZaEa82ZKfQ==");
return PicaResponse.toResponse(cacheCode);
}
}
......@@ -194,10 +194,10 @@ public class AESUtil {
// System.out.println("解密后:" + decrypt);
//请求参数解密处理
String key="bOceDio5f9p8xZfCqVxI+VVHWpGDGP/xDg01FlKi97he2Tovv66hTLzNOgPv7/RbLm2TLzmI1Y8FjAl5Fcr0j3HvHZBLLpgiNBtw+gfbtEde7JsnVo58/mKTm5HBGyB0TWhOq8GZouetmHqC88d8zyNkxIp1fDEs2OSrYMCb1ZY=";
String decrypt = RSAUtil.decrypt(key,procPrivateKey);
String key="am1pnysCRlz80Rl/eTDj/UE/Pe8zkxb2yP73jvrUWEk3x5/lK9hi104MSmsKbl45cPzJfJXBxO+VeItkA63ZqfaUNA0ezdMd7Ord7rGqvWK+4RqAm1T3Qo3lw/5bT0GwgWMWZBrDr30NHCYLmjg6vwVbv3YCEewwQK+rL7bUXu0=";
String decrypt = RSAUtil.decrypt(key,privateKey);
System.out.println(decrypt);
String content="UBcV7wk/VsXm+fcU6fP2qqo/UfYc0M9M184daTGofmfrQAif/hnjO15AdcGiAZMRJEo0y9fOCFy+eTAUAum0Nma4Ylbme4CdyOKI2w5aq8A=";
String content="d9eKA7DGhNx7295N0g82rqzaUOeAvBeuR2gXtOX3Y+VV3ei+zW0BQn9moQgN4mRT8XIzq3x2n3qiqCuOzcDvrlGC0kIcUClM0gt8xDaBw+haVpMAw/7R4FgWNPeVRL5k";
String result = AESUtil.aesDecrypt(content, decrypt);
System.out.println(result);
......
......@@ -85,15 +85,12 @@ public class AccountUtils {
if (org.apache.commons.lang.StringUtils.isBlank(sysCode)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误");
}
String authCodeKey = AccountUtils.getAuthCodeKey(mobile, flag);
//验证码3次校验测试不通过,直接删除
String authCodeKey = getAuthCodeKey(mobile, flag);
String authCodeCount = AUTH_CODE_COUNT_PREFIX + flag + "-" + AESUtil.encryptV0(mobile);
logger.info("验证码缓存信息----->:" + this.getAuthCodeKey(mobile, flag));
if (cacheClient.exists(authCodeCount) && Integer.parseInt(cacheClient.get(authCodeCount)) > 2) {
cacheClient.del(authCodeKey);
}
// if (cacheClient.exists(authCodeCount) && Integer.parseInt(cacheClient.get(authCodeCount)) > 2) {
// cacheClient.del(authCodeKey);
// }
String cacheCode = cacheClient.get(authCodeKey); //从redis获取验证码
// if (org.apache.commons.lang.StringUtils.isBlank(cacheCode)) {
......@@ -101,7 +98,6 @@ public class AccountUtils {
// cacheClient.del(authCodeCount);
// throw new PicaException(PicaResultCode.RESULE_DATA_NONE.code(), "短信验证码已失效,请重新获取");
// }
if (!org.apache.commons.lang.StringUtils.equals(sysCode, cacheCode)) {
cacheClient.incr(authCodeCount);
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误");
......@@ -120,7 +116,6 @@ public class AccountUtils {
}
//获取验证码的key
String authCodeKey = RegisterCodeKeyUtils.getRegisterKey(mobile, sysCode);
//从redis中删除短信验证码,如果能够删除成功,说明验证码正确
//100,99
Long num = cacheClient.decr(authCodeKey);
......@@ -185,10 +180,11 @@ public class AccountUtils {
Long userId = null;
if (productType == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) {
userId = doctorInfoMapper.selectUserIdByAcctId(AcctId);
} else if (productType == AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode()) {
AccountPatientInfoEntity accountPatientInfoEntity = accountPatientInfoMapper.selectByAcctId(AcctId);
userId = accountPatientInfoEntity.getId().longValue();
}
// else if (productType == AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode()) {
// AccountPatientInfoEntity accountPatientInfoEntity = accountPatientInfoMapper.selectByAcctId(AcctId);
// userId = accountPatientInfoEntity.getId().longValue();
// }
return userId;
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册