|
@@ -12,14 +12,7 @@ import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
import com.ruoyi.common.constant.UserConstants;
|
|
@@ -36,6 +29,8 @@ import com.ruoyi.system.service.ISysPostService;
|
|
|
import com.ruoyi.system.service.ISysRoleService;
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
|
|
|
+import static com.ruoyi.framework.web.service.SysLoginService.checkStrongPwd;
|
|
|
+
|
|
|
/**
|
|
|
* 用户信息
|
|
|
*
|
|
@@ -137,6 +132,9 @@ public class SysUserController extends BaseController
|
|
|
{
|
|
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
|
|
}
|
|
|
+ else if ("1".equals(checkStrongPwd(user.getPassword()))) {
|
|
|
+ return AjaxResult.error("密码必须包含数字、大小写字母、特殊符号且大于8位");
|
|
|
+ }
|
|
|
user.setCreateBy(getUsername());
|
|
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
|
|
return toAjax(userService.insertUser(user));
|
|
@@ -146,7 +144,7 @@ public class SysUserController extends BaseController
|
|
|
* 修改用户
|
|
|
*/
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping
|
|
|
+ @PostMapping("/put")
|
|
|
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
|
|
{
|
|
|
userService.checkUserAllowed(user);
|
|
@@ -170,7 +168,7 @@ public class SysUserController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('system:user:remove')")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{userIds}")
|
|
|
+ @GetMapping(value = "/delete/{userIds}")
|
|
|
public AjaxResult remove(@PathVariable Long[] userIds)
|
|
|
{
|
|
|
if (ArrayUtils.contains(userIds, getUserId()))
|
|
@@ -184,11 +182,14 @@ public class SysUserController extends BaseController
|
|
|
* 重置密码
|
|
|
*/
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping("/resetPwd")
|
|
|
+ @PostMapping("/resetPwd")
|
|
|
public AjaxResult resetPwd(@RequestBody SysUser user)
|
|
|
{
|
|
|
//userService.checkUserAllowed(user);
|
|
|
//userService.checkUserDataScope(user.getUserId());
|
|
|
+ if ("1".equals(checkStrongPwd(user.getPassword()))) {
|
|
|
+ return AjaxResult.error("密码必须包含数字、大小写字母、特殊符号且大于8位");
|
|
|
+ }
|
|
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
|
|
user.setUpdateBy(getUsername());
|
|
|
return toAjax(userService.resetPwd(user));
|
|
@@ -203,17 +204,56 @@ public class SysUserController extends BaseController
|
|
|
{
|
|
|
//userService.checkUserAllowed(user);
|
|
|
//userService.checkUserDataScope(user.getUserId());
|
|
|
+ if ("1".equals(checkStrongPwd(user.getPassword()))) {
|
|
|
+ return AjaxResult.error("密码必须包含数字、大小写字母、特殊符号且大于8位");
|
|
|
+ }
|
|
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
|
|
user.setUpdateBy(getUsername());
|
|
|
return toAjax(userService.resetPwd(user));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 登录页修改密码接口,需要放行
|
|
|
+ * @param userName
|
|
|
+ * @param oldPassword
|
|
|
+ * @param newPassword
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/resetPwdLogin")
|
|
|
+ public AjaxResult resetPwdLogin(@RequestParam("userName") String userName, @RequestParam("oldPassword") String oldPassword, @RequestParam("newPassword") String newPassword) {
|
|
|
+ //userService.checkUserAllowed(user);
|
|
|
+ if ("admin".equals(userName)){
|
|
|
+ return AjaxResult.success("不允许操作超级管理员");
|
|
|
+ }
|
|
|
+ SysUser user = userService.selectUserByUserName(userName);
|
|
|
+ if (user == null){
|
|
|
+ return AjaxResult.success("当前用户不存在");
|
|
|
+ }
|
|
|
+ String password = user.getPassword();
|
|
|
+ if (!SecurityUtils.matchesPassword(oldPassword, password))
|
|
|
+ {
|
|
|
+ return AjaxResult.success("修改密码失败,旧密码错误");
|
|
|
+ }
|
|
|
+ if (SecurityUtils.matchesPassword(newPassword, password))
|
|
|
+ {
|
|
|
+ return AjaxResult.success("新密码不能与旧密码相同");
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("1".equals(checkStrongPwd(newPassword))) {
|
|
|
+ return AjaxResult.success("密码必须包含数字、大小写字母、特殊符号且大于8位");
|
|
|
+ }
|
|
|
+ user.setPassword(SecurityUtils.encryptPassword(newPassword));
|
|
|
+ user.setUpdateBy(userName);
|
|
|
+ return toAjax(userService.resetPwdLogin(user));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 状态修改
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping("/changeStatus")
|
|
|
+ @PostMapping("/changeStatus")
|
|
|
public AjaxResult changeStatus(@RequestBody SysUser user)
|
|
|
{
|
|
|
userService.checkUserAllowed(user);
|
|
@@ -242,7 +282,7 @@ public class SysUserController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
|
|
- @PutMapping("/authRole")
|
|
|
+ @PostMapping("/authRole")
|
|
|
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
|
|
|
{
|
|
|
userService.checkUserDataScope(userId);
|