|
|
@@ -11,6 +11,7 @@ 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;
|
|
|
@@ -49,7 +50,7 @@ public class UserServiceImpl implements UserService {
|
|
|
.setName(userDTO.getName())
|
|
|
.setEmail(userDTO.getEmail())
|
|
|
.setPhone(userDTO.getPhone())
|
|
|
- .setPassword(userDTO.getPassword())
|
|
|
+ .setPassword(EncryptUtils.encode(userDTO.getPassword()))
|
|
|
.setType(userDTO.getType())
|
|
|
.setState(userDTO.getType() == UserType.TEACHER ? UserState.CHECKING : UserState.NORMAL));
|
|
|
|
|
|
@@ -77,7 +78,7 @@ public class UserServiceImpl implements UserService {
|
|
|
throw HelperException.of(ExceptionType.NOT_FOUND, "邮箱或验证码错误");
|
|
|
}
|
|
|
|
|
|
- user.setPassword(resetPasswordDTO.getPassword());
|
|
|
+ user.setPassword(EncryptUtils.encode(resetPasswordDTO.getPassword()));
|
|
|
userDAO.save(user);
|
|
|
cacheUtils.remove(Consts.EMAIL_CACHE_NAME, resetPasswordDTO.getUsername());
|
|
|
}
|
|
|
@@ -86,7 +87,7 @@ public class UserServiceImpl implements UserService {
|
|
|
@Override
|
|
|
public UserVO getUserByEmailAndPassword(String email, String password) {
|
|
|
return userDAO
|
|
|
- .findByEmailAndPassword(email, password)
|
|
|
+ .findByEmailAndPassword(email, EncryptUtils.encode(password))
|
|
|
.map(UserVO::new)
|
|
|
.orElseThrow(() -> HelperException.of(ExceptionType.NOT_FOUND, "邮箱或密码错误"));
|
|
|
}
|