Jelajahi Sumber

fix:用户新增或编辑时的密码已在前端加密

wangzaijun 7 bulan lalu
induk
melakukan
a130751548

+ 0 - 4
service-manage/src/main/java/com/simuwang/manage/api/LoginController.java

@@ -14,7 +14,6 @@ import com.simuwang.shiro.utils.UserUtils;
 import com.smppw.common.pojo.ResultVo;
 import com.smppw.common.pojo.enums.status.ResultCode;
 import jakarta.validation.Valid;
-import org.apache.shiro.authz.annotation.RequiresAuthentication;
 import org.apache.shiro.subject.Subject;
 import org.springframework.web.bind.annotation.*;
 
@@ -72,7 +71,6 @@ public class LoginController {
      * 退出登录接口,登录用户才能访问
      */
     @SystemLog(value = "登出", type = SystemLog.Type.LOGOUT)
-    @RequiresAuthentication
     @PostMapping("/logout")
     public ResultVo<Boolean> logout() {
         Subject subject = UserUtils.getSubject();
@@ -88,7 +86,6 @@ public class LoginController {
      *
      * @return 当前登录用户的角色权限信息
      */
-    @RequiresAuthentication
     @GetMapping("/user-info")
     public UserInfoVO getUserInfo() {
         return this.loginService.getUserInfo();
@@ -99,7 +96,6 @@ public class LoginController {
      *
      * @param command 修改密码对象
      */
-    @RequiresAuthentication
     @SystemLog(value = "修改密码", type = SystemLog.Type.UPDATE)
     @PostMapping("update-pwd")
     public boolean updatePwd(@Valid @RequestBody UserUpdatePwdCmd command) {

+ 0 - 2
service-manage/src/main/java/com/simuwang/manage/api/system/SysLogController.java

@@ -5,7 +5,6 @@ import com.simuwang.base.pojo.dto.sys.LogQuery;
 import com.simuwang.base.pojo.vo.sys.SysLogVO;
 import com.simuwang.logging.SystemLog;
 import com.simuwang.manage.service.system.SysLogService;
-import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -41,7 +40,6 @@ public class SysLogController {
      * @return /
      */
     @SystemLog(value = "清空日志", type = SystemLog.Type.DELETE)
-    @RequiresPermissions("SYS:LOG:TRUNCATE")
     @DeleteMapping
     public boolean truncate() {
         return this.service.truncate();

+ 5 - 7
service-manage/src/main/java/com/simuwang/manage/service/impl/system/SysUserServiceImpl.java

@@ -93,12 +93,13 @@ public class SysUserServiceImpl implements SysUserService {
         UserAddCmd cmd = (UserAddCmd) command;
         SysUserDO entity = cmd.toEntity();
         String originalPwd = cmd.getPassword();
+        // 密码在前端已加密
         if (StrUtil.isBlank(originalPwd)) {
             originalPwd = this.properties.getDefaultPwd();
+            String publicKey = this.properties.getSecurityRsa().getPublicKey();
+            String password = new RSA(null, publicKey).encryptBase64(originalPwd, KeyType.PublicKey);
+            entity.setPassword(password);
         }
-        String publicKey = this.properties.getSecurityRsa().getPublicKey();
-        String password = new RSA(null, publicKey).encryptBase64(originalPwd, KeyType.PublicKey);
-        entity.setPassword(password);
         this.mapper.insert(entity);
     }
 
@@ -106,10 +107,7 @@ public class SysUserServiceImpl implements SysUserService {
     public <C extends BaseEditCmd<SysUserDO>> void update(C command) {
         UserEditCmd cmd = (UserEditCmd) command;
         SysUserDO entity = cmd.toEntity();
-        String originalPwd = cmd.getPassword();
-        String publicKey = this.properties.getSecurityRsa().getPublicKey();
-        String password = new RSA(null, publicKey).encryptBase64(originalPwd, KeyType.PublicKey);
-        entity.setPassword(password);
+        // 密码在前端已加密
         this.mapper.updateById(entity);
     }