添加了修改密码 忘记密码 邀请码的生成与验证
Change-Id: I88ffc40e64943c7c9fcd411c763e788e6e49c834
diff --git a/src/main/java/com/example/g8backend/controller/UserSecurityController.java b/src/main/java/com/example/g8backend/controller/UserSecurityController.java
new file mode 100644
index 0000000..34bbb96
--- /dev/null
+++ b/src/main/java/com/example/g8backend/controller/UserSecurityController.java
@@ -0,0 +1,24 @@
+package com.example.g8backend.controller;
+
+import com.example.g8backend.dto.PasswordChangeDTO;
+import com.example.g8backend.service.IUserSecurityService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("/user/security")
+public class UserSecurityController {
+ @Autowired
+ private IUserSecurityService userSecurityService;
+
+ @PutMapping("/change-password")
+ public ResponseEntity<?> changePassword(@RequestBody PasswordChangeDTO dto) {
+ Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+ Long userId = (Long) authentication.getPrincipal();
+ userSecurityService.changePassword(userId, dto.getOldPassword(), dto.getNewPassword());
+ return ResponseEntity.ok("密码修改成功");
+ }
+}
\ No newline at end of file