|
|
@@ -11,7 +11,6 @@ import nju.seec.helper.enums.UserType;
|
|
|
import nju.seec.helper.exception.HelperException;
|
|
|
import nju.seec.helper.service.UserService;
|
|
|
import nju.seec.helper.util.Consts;
|
|
|
-import nju.seec.helper.util.EncryptUtils;
|
|
|
import nju.seec.helper.util.RedisCacheUtils;
|
|
|
import nju.seec.helper.vo.UserVO;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -24,11 +23,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
public class UserServiceImpl implements UserService {
|
|
|
private final RedisCacheUtils cacheUtils;
|
|
|
private final UserDAO userDAO;
|
|
|
-// private final static Map<String, UserType> EMAIL_SUFFIX_AND_USER_TYPE_MAP =
|
|
|
-// ImmutableMap.of(
|
|
|
-// "smail.nju.edu.cn", UserType.STUDENT,
|
|
|
-// "nju.edu.cn", UserType.TEACHER
|
|
|
-// );
|
|
|
|
|
|
public UserServiceImpl(UserDAO userDAO, RedisCacheUtils cacheUtils) {
|
|
|
this.userDAO = userDAO;
|
|
|
@@ -55,7 +49,7 @@ public class UserServiceImpl implements UserService {
|
|
|
.setName(userDTO.getName())
|
|
|
.setEmail(userDTO.getEmail())
|
|
|
.setPhone(userDTO.getPhone())
|
|
|
- .setPassword(EncryptUtils.encode(userDTO.getPassword()))
|
|
|
+ .setPassword(userDTO.getPassword())
|
|
|
.setType(userDTO.getType())
|
|
|
.setState(userDTO.getType() == UserType.TEACHER ? UserState.CHECKING : UserState.NORMAL));
|
|
|
|
|
|
@@ -83,7 +77,7 @@ public class UserServiceImpl implements UserService {
|
|
|
throw HelperException.of(ExceptionType.NOT_FOUND, "邮箱或验证码错误");
|
|
|
}
|
|
|
|
|
|
- user.setPassword(EncryptUtils.encode(resetPasswordDTO.getPassword()));
|
|
|
+ user.setPassword(resetPasswordDTO.getPassword());
|
|
|
userDAO.save(user);
|
|
|
cacheUtils.remove(Consts.EMAIL_CACHE_NAME, resetPasswordDTO.getUsername());
|
|
|
}
|
|
|
@@ -92,7 +86,7 @@ public class UserServiceImpl implements UserService {
|
|
|
@Override
|
|
|
public UserVO getUserByEmailAndPassword(String email, String password) {
|
|
|
return userDAO
|
|
|
- .findByEmailAndPassword(email, EncryptUtils.encode(password))
|
|
|
+ .findByEmailAndPassword(email, password)
|
|
|
.map(UserVO::new)
|
|
|
.orElseThrow(() -> HelperException.of(ExceptionType.NOT_FOUND, "邮箱或密码错误"));
|
|
|
}
|