|
|
@@ -5,6 +5,7 @@ import com.uas.sso.core.Status;
|
|
|
import com.uas.sso.entity.*;
|
|
|
import com.uas.sso.service.UserService;
|
|
|
import com.uas.sso.support.SystemSession;
|
|
|
+import org.springframework.util.Assert;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
@@ -258,12 +259,8 @@ public class UpdateUserController extends BaseController {
|
|
|
@RequestMapping(value = "/setMobile", method = RequestMethod.POST)
|
|
|
public ModelMap updateMobile(String mobile, String code, @RequestParam String token) {
|
|
|
// 校验空参数
|
|
|
- if (StringUtils.isEmpty(mobile)) {
|
|
|
- return error("手机号不能为空");
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(code)) {
|
|
|
- return error("验证码不能为空");
|
|
|
- }
|
|
|
+ Assert.hasText(mobile, "手机号不能为空");
|
|
|
+ Assert.hasText(code, "验证码不能为空");
|
|
|
|
|
|
// 从session中获取用户信息
|
|
|
User user = (User) request.getSession().getAttribute("user");
|
|
|
@@ -272,7 +269,7 @@ public class UpdateUserController extends BaseController {
|
|
|
}
|
|
|
|
|
|
// 校验手机号是否被使用
|
|
|
- if (userService.mobileHasRegistered(mobile)){
|
|
|
+ if (!mobile.equals(user.getMobile()) && userService.mobileHasRegistered(mobile)){
|
|
|
return error("手机号已注册");
|
|
|
}
|
|
|
|
|
|
@@ -284,10 +281,10 @@ public class UpdateUserController extends BaseController {
|
|
|
|
|
|
// 校验验证码
|
|
|
checkMobileCode(token, mobile, code);
|
|
|
- tokenService.delete(token);
|
|
|
|
|
|
// 修改手机号
|
|
|
userService.updateMobile(user.getUserUU(), mobile);
|
|
|
+ tokenService.delete(token);
|
|
|
return success();
|
|
|
}
|
|
|
|