1.优化redis中验证码过期的NPE
This commit is contained in:
@@ -53,7 +53,7 @@ public class EmailServiceImpl implements EmailService {
|
||||
}
|
||||
|
||||
try{
|
||||
int expireTime = 300;
|
||||
int expireTime = 1800;
|
||||
// 3. 发送邮箱验证码到用户邮箱
|
||||
String systemName = configService.get("systemName");
|
||||
String time = LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.hula.core.user.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.auth0.jwt.interfaces.Claim;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -77,7 +78,14 @@ public class LoginServiceImpl implements LoginService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void normalRegister(RegisterReq req) {
|
||||
String emailCode = RedisUtils.hget("emailCode", req.getUuid()).toString();
|
||||
String emailCode;
|
||||
Object codeObj = RedisUtils.hget("emailCode", req.getUuid());
|
||||
if (ObjectUtil.isNotNull(codeObj)) {
|
||||
emailCode = codeObj.toString();
|
||||
} else {
|
||||
throw new BizException("验证码已过期");
|
||||
}
|
||||
|
||||
if(StrUtil.isEmpty(emailCode) || !emailCode.equals(req.getCode())){
|
||||
throw new BizException("验证码错误!");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.hula.core.user.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.hula.common.event.UserBlackEvent;
|
||||
@@ -186,7 +187,14 @@ public class UserServiceImpl implements UserService {
|
||||
@Override
|
||||
public Boolean bindEmail(Long uid, BindEmailReq req) {
|
||||
// 1.校验验证码
|
||||
String emailCode = RedisUtils.hget("emailCode", req.getUuid()).toString();
|
||||
String emailCode;
|
||||
Object codeObj = RedisUtils.hget("emailCode", req.getUuid());
|
||||
if (ObjectUtil.isNotNull(codeObj)) {
|
||||
emailCode = codeObj.toString();
|
||||
} else {
|
||||
throw new BizException("验证码已过期");
|
||||
}
|
||||
|
||||
if(StrUtil.isEmpty(emailCode) || !emailCode.equals(req.getCode())){
|
||||
throw new BizException("验证码错误!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user