From eaeb8d759eecb40b22caee44c2077f4447f452d2 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 17 Dec 2024 14:40:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=89=B9=E6=AE=8A=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E5=AF=86=E7=A0=81=E4=BF=AE=E6=94=B9=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/SysProfileController.java | 14 ++++++++------ ruoyi-ui/src/api/system/user.js | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysProfileController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysProfileController.java index 7163c4445..5530bf1a5 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysProfileController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysProfileController.java @@ -1,6 +1,7 @@ package com.ruoyi.system.controller; import java.util.Arrays; +import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -93,11 +94,13 @@ public class SysProfileController extends BaseController */ @Log(title = "个人信息", businessType = BusinessType.UPDATE) @PutMapping("/updatePwd") - public AjaxResult updatePwd(String oldPassword, String newPassword) + public AjaxResult updatePwd(@RequestBody Map params) { - String username = SecurityUtils.getUsername(); - SysUser user = userService.selectUserByUserName(username); - String password = user.getPassword(); + String oldPassword = params.get("oldPassword"); + String newPassword = params.get("newPassword"); + LoginUser loginUser = SecurityUtils.getLoginUser(); + String userName = loginUser.getUsername(); + String password = loginUser.getSysUser().getPassword(); if (!SecurityUtils.matchesPassword(oldPassword, password)) { return error("修改密码失败,旧密码错误"); @@ -107,10 +110,9 @@ public class SysProfileController extends BaseController return error("新密码不能与旧密码相同"); } newPassword = SecurityUtils.encryptPassword(newPassword); - if (userService.resetUserPwd(username, newPassword) > 0) + if (userService.resetUserPwd(userName, newPassword) > 0) { // 更新缓存用户密码 - LoginUser loginUser = SecurityUtils.getLoginUser(); loginUser.getSysUser().setPassword(newPassword); tokenService.setLoginUser(loginUser); return success(); diff --git a/ruoyi-ui/src/api/system/user.js b/ruoyi-ui/src/api/system/user.js index 9b0211a5f..b5e3edd81 100644 --- a/ruoyi-ui/src/api/system/user.js +++ b/ruoyi-ui/src/api/system/user.js @@ -96,7 +96,7 @@ export function updateUserPwd(oldPassword, newPassword) { return request({ url: '/system/user/profile/updatePwd', method: 'put', - params: data + data: data }) }