From d1d3ca6f708ec971c6d9e9c2804f2f53c45d8a00 Mon Sep 17 00:00:00 2001 From: vincentlu <t1341870251@gmail.com> Date: 星期一, 10 二月 2025 17:01:03 +0800 Subject: [PATCH] # --- rsf-server/src/main/java/com/vincent/rsf/server/system/controller/AuthController.java | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-) diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/system/controller/AuthController.java b/rsf-server/src/main/java/com/vincent/rsf/server/system/controller/AuthController.java index d1744e9..f2a4728 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/system/controller/AuthController.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/system/controller/AuthController.java @@ -12,12 +12,15 @@ import com.vincent.rsf.server.system.controller.result.LoginResult; import com.vincent.rsf.server.system.controller.result.MenuVo; import com.vincent.rsf.server.system.entity.Menu; +import com.vincent.rsf.server.system.entity.Tenant; import com.vincent.rsf.server.system.entity.User; import com.vincent.rsf.server.system.entity.UserLogin; import com.vincent.rsf.server.system.service.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -30,7 +33,6 @@ * Created by vincent on 1/30/2024 */ @RestController -//@RequestMapping("") public class AuthController extends BaseController { @Resource @@ -64,7 +66,8 @@ String accessToken = JwtUtil.buildToken(new JwtSubject(username, user.getTenantId()), configProperties.getTokenExpireTime(), configProperties.getTokenKey()); userLoginService.saveAsync(user.getId(), accessToken, UserLogin.TYPE_LOGIN, tenantId, null, request); - return R.ok("Login Success").add(new LoginResult(accessToken, user)); + Tenant tenant = tenantService.getById(user.getTenantId()); + return R.ok("Login Success").add(new LoginResult(accessToken, user, tenant.getName())); } @GetMapping("/tenant/list") @@ -103,11 +106,10 @@ return R.error("Save Fail"); } - @PreAuthorize("hasAuthority('sys:auth:password')") - @OperationLog - @PostMapping("/auth/password") - public R updatePassword(@RequestBody UpdatePasswordParam param) { - if (Cools.isEmpty(param.getOldPassword(), param.getPassword())) { + @OperationLog("Reset Password") + @PostMapping("/auth/reset/password") + public R resetPassword(@RequestBody UpdatePasswordParam param) { + if (Cools.isEmpty(param.getOldPassword(), param.getNewPassword())) { return R.error("Parameters Cannot Be Empty"); } Long userId = getLoginUserId(); @@ -115,15 +117,15 @@ return R.error("Please Login First"); } if (!userService.comparePassword(userService.getById(userId).getPassword(), param.getOldPassword())) { - return R.error("The Origin Password Was Incorrect"); + return R.parse("408-The Current Password Was Incorrect"); } User user = new User(); user.setId(userId); - user.setPassword(userService.encodePassword(param.getPassword())); + user.setPassword(userService.encodePassword(param.getNewPassword())); if (userService.updateById(user)) { - return R.ok("Update Success"); + return R.ok("Reset Password Success"); } - return R.error("Update Fail"); + return R.error("Reset Password Fail"); } -- Gitblit v1.9.1