🐛 Fix: [后台]:修改验证码校验逻辑,解决验证为空能通过校验的bug

This commit is contained in:
fanxb 2019-08-01 18:31:40 +08:00
parent 29ca1f0676
commit af1d063709
3 changed files with 8 additions and 9 deletions

View File

@ -6,7 +6,7 @@ import com.fanxb.bookmark.business.bookmark.entity.MoveNodeBody;
import com.fanxb.bookmark.common.constant.EsConstant;
import com.fanxb.bookmark.common.entity.Bookmark;
import com.fanxb.bookmark.common.entity.EsEntity;
import com.fanxb.bookmark.common.exception.CustomException;
import com.fanxb.bookmark.common.exception.FormDataException;
import com.fanxb.bookmark.common.util.EsUtil;
import com.fanxb.bookmark.common.util.UserContextHolder;
import lombok.extern.slf4j.Slf4j;
@ -203,7 +203,7 @@ public class BookmarkService {
try {
bookmarkDao.insertOne(bookmark);
} catch (DuplicateKeyException e) {
throw new CustomException("同级目录下不能存在相同名称的数据");
throw new FormDataException("同级目录下不能存在相同名称的数据");
}
//如果是书签插入到es中
if (bookmark.getType() == 0) {

View File

@ -7,7 +7,6 @@ import com.fanxb.bookmark.business.user.entity.RegisterBody;
import com.fanxb.bookmark.common.constant.Constant;
import com.fanxb.bookmark.common.entity.MailInfo;
import com.fanxb.bookmark.common.entity.User;
import com.fanxb.bookmark.common.exception.CustomException;
import com.fanxb.bookmark.common.exception.FormDataException;
import com.fanxb.bookmark.common.util.*;
import org.springframework.beans.factory.annotation.Autowired;
@ -71,8 +70,8 @@ public class UserService {
public void register(RegisterBody body) {
String codeKey = Constant.authCodeKey(body.getEmail());
String realCode = RedisUtil.get(codeKey, String.class);
if ((!StringUtil.isEmpty(realCode)) && (!realCode.equals(body.getAuthCode()))) {
throw new CustomException("验证码错误");
if (StringUtil.isEmpty(realCode) || (!realCode.equals(body.getAuthCode()))) {
throw new FormDataException("验证码错误");
}
RedisUtil.delete(codeKey);
User user = userDao.selectByUsernameOrEmail(body.getUsername(), body.getEmail());
@ -148,10 +147,10 @@ public class UserService {
/**
* Description: 根据userId获取用户信息
*
* @author fanxb
* @date 2019/7/30 15:57
* @param userId userId
* @return com.fanxb.bookmark.common.entity.User
* @author fanxb
* @date 2019/7/30 15:57
*/
public User getUserInfo(int userId) {
return userDao.selectByUserId(userId);

View File

@ -29,7 +29,7 @@ spring:
lettuce:
pool:
max-active: 20
max-wait: 1000ms
max-wait: 500ms
max-idle: 20
min-idle: 2
datasource: