Commit 631e446d authored by 技术部-任文超's avatar 技术部-任文超

重新提交代码

parent 7125eb19
...@@ -186,7 +186,7 @@ public class UserController implements IBaseController { ...@@ -186,7 +186,7 @@ public class UserController implements IBaseController {
} }
String verificationCode = successResult.getMsg(); String verificationCode = successResult.getMsg();
// 执行短信验证码检查 // 执行短信验证码检查
smsValidForFastLogin(phoneNo, verificationCode); verifyPhoneAndCode(phoneNo, verificationCode);
User user = userService.findByPhoneWithCache(phoneNo); User user = userService.findByPhoneWithCache(phoneNo);
if (user != null && !user.getEnable()) { if (user != null && !user.getEnable()) {
LOGGER.error("用户不存在,或者已经注销,phoneNo:{}",phoneNo); LOGGER.error("用户不存在,或者已经注销,phoneNo:{}",phoneNo);
...@@ -272,7 +272,7 @@ public class UserController implements IBaseController { ...@@ -272,7 +272,7 @@ public class UserController implements IBaseController {
if (null == registerFrom) { if (null == registerFrom) {
registerFrom = 1L; registerFrom = 1L;
} }
smsValidForRegister(phoneNo, verificationCode); verifyPhoneAndCode(phoneNo, verificationCode);
if (userService.exist(phoneNo)) { if (userService.exist(phoneNo)) {
LOGGER.info("用户注册失败,该手机号已经被注册:register -> registerFrom:{}, phoneNo:{}", registerFrom, phoneNo); LOGGER.info("用户注册失败,该手机号已经被注册:register -> registerFrom:{}, phoneNo:{}", registerFrom, phoneNo);
return JsonResult.buildErrorStateResult("该手机号已经被注册", null); return JsonResult.buildErrorStateResult("该手机号已经被注册", null);
...@@ -336,7 +336,7 @@ public class UserController implements IBaseController { ...@@ -336,7 +336,7 @@ public class UserController implements IBaseController {
if (password.length() < 6 || password.length() > 12) { if (password.length() < 6 || password.length() > 12) {
return JsonResult.buildErrorStateResult("密码应为6-12位", null); return JsonResult.buildErrorStateResult("密码应为6-12位", null);
} }
smsValidForRegister(phoneNo, verificationCode); verifyPhoneAndCode(phoneNo, verificationCode);
if (!userService.exist(phoneNo)) { if (!userService.exist(phoneNo)) {
LOGGER.info("修改密码失败,该手机号尚未注册, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo); LOGGER.info("修改密码失败,该手机号尚未注册, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo);
return JsonResult.buildErrorStateResult("该手机号尚未注册", null); return JsonResult.buildErrorStateResult("该手机号尚未注册", null);
...@@ -486,27 +486,14 @@ public class UserController implements IBaseController { ...@@ -486,27 +486,14 @@ public class UserController implements IBaseController {
} }
/** /**
* 注册时校验短信验证码 * 校验短信验证码
* @param phoneNo * @param phoneNo
* @param verificationCode * @param verificationCode
*/ */
private void smsValidForRegister(String phoneNo, String verificationCode) { private void verifyPhoneAndCode(String phoneNo, String verificationCode) {
if (!smsService.validRegisterOrResetPasswdVerificationCode(phoneNo, verificationCode)) { if (!smsService.verifyPhoneAndCode(phoneNo, verificationCode)) {
smsReSendOrNot(phoneNo); smsReSendOrNot(phoneNo);
LOGGER.info("用户快速注册,验证码校验失败,phoneNo:{} , verificationCode:{}", phoneNo, verificationCode); LOGGER.info("验证码校验失败,phoneNo:{} , verificationCode:{}", phoneNo, verificationCode);
throw new VerificationCodeErrorException("短信验证码错误");
}
}
/**
* 登录时校验短信验证码
* @param phoneNo
* @param verificationCode
*/
private void smsValidForFastLogin(String phoneNo, String verificationCode) {
if (!smsService.validateFastLoginVerificationCode(phoneNo, verificationCode)) {
smsReSendOrNot(phoneNo);
LOGGER.info("用户快速登录,验证码校验失败,phoneNo:{} , verificationCode:{}", phoneNo, verificationCode);
throw new VerificationCodeErrorException("短信验证码错误"); throw new VerificationCodeErrorException("短信验证码错误");
} }
} }
......
...@@ -16,10 +16,6 @@ public interface ISmsService { ...@@ -16,10 +16,6 @@ public interface ISmsService {
void sendAfterRegister(String phoneNo,String contentId); void sendAfterRegister(String phoneNo,String contentId);
boolean validRegisterOrResetPasswdVerificationCode(String phoneNo, String smsVerificationCode);
boolean validateFastLoginVerificationCode(String phoneNo, String verificationCode);
/** /**
* 验证手机号和验证码是否匹配 * 验证手机号和验证码是否匹配
* @param phoneNo 手机号 * @param phoneNo 手机号
......
...@@ -77,31 +77,6 @@ public class SmsServiceImpl implements ISmsService { ...@@ -77,31 +77,6 @@ public class SmsServiceImpl implements ISmsService {
} }
} }
@Override
public boolean validRegisterOrResetPasswdVerificationCode(String phoneNo, String smsVerificationCode) {
//if (StringUtils.isEmpty(smsVerificationCode) || smsVerificationCode.length() != SMS_VERIFICATION_MAXLEN) {
// return false;
//}
String key = Constants.REDIS_PREFIX_VERIFICATION_CODE + phoneNo;
String randomCode = stringRedisTemplate.opsForValue().get(key);
if (StringUtils.isEmpty(randomCode)) {
return false;
}
String[] arr = randomCode.split(":");
String uniqueId = arr[0];
String code = arr[1];
log.info("arr: {}", arr);
for (String i: arr) {
log.info("arr[i]: {}", i);
}
return confirmSms(smsVerificationCode, uniqueId, code);
}
@Override
public boolean validateFastLoginVerificationCode(String phoneNo, String verificationCode) {
return verifyPhoneAndCode(phoneNo, verificationCode);
}
/** /**
* 检查验证码是否正确 * 检查验证码是否正确
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment