|
@@ -7,10 +7,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ozs.common.core.controller.BaseController;
|
|
|
import com.ozs.common.core.domain.AjaxResult;
|
|
|
|
|
|
+import com.ozs.common.core.domain.entity.SysUser;
|
|
|
+import com.ozs.common.core.domain.model.LoginUser;
|
|
|
import com.ozs.common.utils.ImgUtil;
|
|
|
import com.ozs.common.utils.MinioUtils;
|
|
|
+import com.ozs.common.utils.SecurityUtils;
|
|
|
import com.ozs.common.utils.StringUtils;
|
|
|
import com.ozs.common.utils.uuid.IdUtils;
|
|
|
+import com.ozs.framework.web.service.TokenService;
|
|
|
import com.ozs.service.entity.BaseCameraManagement;
|
|
|
import com.ozs.service.entity.BaseRailwayManagement;
|
|
|
import com.ozs.service.entity.MsgAlarm;
|
|
@@ -46,6 +50,11 @@ import java.util.UUID;
|
|
|
@RequestMapping("/app/mine")
|
|
|
@Slf4j
|
|
|
public class GeoHazardMineController extends BaseController {
|
|
|
+ public static final String PW_PATTERN = "^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,20}$";
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService userService;
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
@Value("${file.avatarUrl:#{null}}")
|
|
|
private String avatarURL;
|
|
|
@Value("${file.filreUrl:#{null}}")
|
|
@@ -98,9 +107,29 @@ public class GeoHazardMineController extends BaseController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/updatePassword", method = RequestMethod.POST)
|
|
|
@ApiOperation("app修改密码")
|
|
|
- public AjaxResult updatePassword(@RequestParam("userId") String userId, @RequestParam("newPwd") String newPwd) {
|
|
|
- sysUserService.updatePassword(userId, newPwd);
|
|
|
- return AjaxResult.success();
|
|
|
+ public AjaxResult updatePassword(@RequestBody SysUser user) {
|
|
|
+// sysUserService.updatePassword(userId, newPwd);
|
|
|
+// return AjaxResult.success();
|
|
|
+ LoginUser loginUser = getLoginUser();
|
|
|
+ if (!SecurityUtils.matchesPassword(user.getPassword(), loginUser.getPassword())) {
|
|
|
+ return error("修改密码失败,旧密码错误");
|
|
|
+ }
|
|
|
+ boolean matches = user.getNewPassword().matches(PW_PATTERN);
|
|
|
+ if (!matches) {
|
|
|
+ return error("您的密码太简单!需要包含大小英文、数字、特殊字符、并且长度8-20");
|
|
|
+ }
|
|
|
+ if (SecurityUtils.matchesPassword(user.getNewPassword(), loginUser.getPassword())) {
|
|
|
+ return error("新密码不能与旧密码相同");
|
|
|
+ }
|
|
|
+ user.setPassword(SecurityUtils.encryptPassword(user.getNewPassword()));
|
|
|
+ user.setUpdateBy(getUsername());
|
|
|
+ if (userService.resetPwd(user) > 0) {
|
|
|
+ // 更新缓存用户密码
|
|
|
+ loginUser.getUser().setPassword(SecurityUtils.encryptPassword(user.getNewPassword()));
|
|
|
+ tokenService.setLoginUser(loginUser);
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+ return error("修改密码异常,请联系管理员");
|
|
|
}
|
|
|
|
|
|
/**
|