#
vincentlu
2025-02-10 07ce1e9ee6f723882c9b49e23215745ee719633a
rsf-server/src/main/java/com/vincent/rsf/server/system/controller/AuthController.java
@@ -16,8 +16,10 @@
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;
@@ -103,11 +105,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 +116,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");
    }