|
@@ -368,21 +368,19 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
if (StrUtil.hasEmpty(loginReq.getPhone(), loginReq.getCode())) {
|
|
if (StrUtil.hasEmpty(loginReq.getPhone(), loginReq.getCode())) {
|
|
|
throw BusinessRuntimeException.getInstance("请输入对应信息");
|
|
throw BusinessRuntimeException.getInstance("请输入对应信息");
|
|
|
}
|
|
}
|
|
|
- if (!Constant.LOGIN_CODE.equals(loginReq.getCode())) {
|
|
|
|
|
- DateTime now = DateTime.now();
|
|
|
|
|
- PhoneCode phoneCode = phoneCodeMapper.selectOne(Wrappers.lambdaQuery(PhoneCode.class).eq(PhoneCode::getPhone, loginReq.getPhone()).last("limit 1"));
|
|
|
|
|
- if (phoneCode == null || StrUtil.isEmpty(phoneCode.getCode())) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("请重新获取手机验证码");
|
|
|
|
|
- }
|
|
|
|
|
- //3分钟失效
|
|
|
|
|
- Date updateTime = phoneCode.getUpdateTime();
|
|
|
|
|
- DateTime afterFiveMinutes = DateUtil.offsetMinute(updateTime, 3);
|
|
|
|
|
- if (now.isAfter(afterFiveMinutes)) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("手机验证码已失效,请重新获取");
|
|
|
|
|
- }
|
|
|
|
|
- if (!StrUtil.equals(loginReq.getCode(), phoneCode.getCode())) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("手机验证码错误,请重新输入");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ DateTime now = DateTime.now();
|
|
|
|
|
+ PhoneCode phoneCode = phoneCodeMapper.selectOne(Wrappers.lambdaQuery(PhoneCode.class).eq(PhoneCode::getPhone, loginReq.getPhone()).last("limit 1"));
|
|
|
|
|
+ if (phoneCode == null || StrUtil.isEmpty(phoneCode.getCode())) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("请重新获取手机验证码");
|
|
|
|
|
+ }
|
|
|
|
|
+ //3分钟失效
|
|
|
|
|
+ Date updateTime = phoneCode.getUpdateTime();
|
|
|
|
|
+ DateTime afterFiveMinutes = DateUtil.offsetMinute(updateTime, 3);
|
|
|
|
|
+ if (now.isAfter(afterFiveMinutes)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("手机验证码已失效,请重新获取");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!StrUtil.equals(loginReq.getCode(), phoneCode.getCode())) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("手机验证码错误,请重新输入");
|
|
|
}
|
|
}
|
|
|
wrapper.eq(User::getLoginPhone, loginReq.getPhone());
|
|
wrapper.eq(User::getLoginPhone, loginReq.getPhone());
|
|
|
}
|
|
}
|
|
@@ -390,16 +388,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
if (StrUtil.isEmpty(loginReq.getEmail())) {
|
|
if (StrUtil.isEmpty(loginReq.getEmail())) {
|
|
|
throw BusinessRuntimeException.getInstance("邮箱不能为空");
|
|
throw BusinessRuntimeException.getInstance("邮箱不能为空");
|
|
|
}
|
|
}
|
|
|
- if (!Constant.LOGIN_CODE.equals(loginReq.getCode())) {
|
|
|
|
|
- String code = redisService.getStr(RedisService.key.EMAIL_CODE_KEY.getNameFormat(loginReq.getEmail()));
|
|
|
|
|
- if (StrUtil.isEmpty(code)) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("邮箱验证码已失效,请重新获取");
|
|
|
|
|
- }
|
|
|
|
|
- if (!StrUtil.equals(loginReq.getCode(), code)) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("邮箱验证码错误,请重新输入");
|
|
|
|
|
- }
|
|
|
|
|
- redisService.del(RedisService.key.EMAIL_CODE_KEY.getNameFormat(loginReq.getEmail()));
|
|
|
|
|
|
|
+ String code = redisService.getStr(RedisService.key.EMAIL_CODE_KEY.getNameFormat(loginReq.getEmail()));
|
|
|
|
|
+ if (StrUtil.isEmpty(code)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("邮箱验证码已失效,请重新获取");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!StrUtil.equals(loginReq.getCode(), code)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("邮箱验证码错误,请重新输入");
|
|
|
}
|
|
}
|
|
|
|
|
+ redisService.del(RedisService.key.EMAIL_CODE_KEY.getNameFormat(loginReq.getEmail()));
|
|
|
wrapper.eq(User::getEmail, loginReq.getEmail());
|
|
wrapper.eq(User::getEmail, loginReq.getEmail());
|
|
|
}
|
|
}
|
|
|
if (loginReq.getType() == 3){
|
|
if (loginReq.getType() == 3){
|