|
@@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.mail.MessagingException;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpSession;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.net.URLEncoder;
|
|
@@ -328,6 +329,7 @@ public class UserLogicImpl extends BaseLogic implements UserLogic {
|
|
|
// LOG.error(result.getMsg());
|
|
|
// return result;
|
|
|
// }
|
|
|
+ System.out.println(userDTO.getEmail());
|
|
|
if (!EmailValidator.getInstance().isValid(userDTO.getEmail())){
|
|
|
result.init(ResponseStatus.FAILED, "邮箱输入非法", receiver);
|
|
|
LOG.error(result.getMsg());
|
|
@@ -585,14 +587,14 @@ public class UserLogicImpl extends BaseLogic implements UserLogic {
|
|
|
@Override
|
|
|
public ResponseResult<UserVO> updateUserEmail(UserVO userVO, HttpServletRequest request) {
|
|
|
ResponseResult<UserVO> result = new ResponseResult<>();
|
|
|
- Long userId = Long.parseLong((String) request.getSession().getAttribute("userId"));
|
|
|
+ Long userId = userVO.getId();
|
|
|
+ User user = userService.findById(userId);
|
|
|
try {
|
|
|
- if (userId == null)
|
|
|
+ if(userId == null || !user.getPassword().equals(userVO.getPassword()))
|
|
|
throw new Exception("用户未登录");
|
|
|
if (!verifyCodeService.validateVerifyCode("email", userVO.getEmail(), userVO.getVerifyCode()))
|
|
|
throw new Exception("验证码或邮箱填写错误");
|
|
|
- User user = userService.findById(userId);
|
|
|
- if (!userVO.getEmail().equals(user.getEmail()) && userService.findByEmail(userVO.getEmail()) != null)
|
|
|
+ if (userVO.getEmail().equals(user.getEmail()) || userService.findByEmail(userVO.getEmail()) != null)
|
|
|
throw new Exception("该邮箱已被注册");
|
|
|
user.setEmail(userVO.getEmail());
|
|
|
userVO = userVOWrapper.wrap(userService.update(user));
|