diff --git a/src/main/java/me/gt/snaptickets/controller/UserController.java b/src/main/java/me/gt/snaptickets/controller/UserController.java index 9352eef..125fe41 100644 --- a/src/main/java/me/gt/snaptickets/controller/UserController.java +++ b/src/main/java/me/gt/snaptickets/controller/UserController.java @@ -2,6 +2,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import me.gt.snaptickets.dto.ResetPasswordDto; import me.gt.snaptickets.dto.UserDto; import me.gt.snaptickets.model.Order; import me.gt.snaptickets.model.User; @@ -62,6 +63,12 @@ public ResponseEntity loginUser(@RequestParam String identifier, @Reques return ResponseEntity.ok().body(Map.of("username", user.getUsername(), "token", token)); } + @Operation(summary = "重設密碼") + @PutMapping("/auth/reset-password") + public ResponseEntity resetPassword(@RequestBody ResetPasswordDto resetPasswordDto) { + return updatePassword(resetPasswordDto.getUsername(), resetPasswordDto.getOldPassword(), resetPasswordDto.getNewPassword()); + } + @Operation(summary = "查詢帳號資料") @GetMapping("/user/info/{username}") public ResponseEntity getUserByUsername(@PathVariable String username) { diff --git a/src/main/java/me/gt/snaptickets/dto/ResetPasswordDto.java b/src/main/java/me/gt/snaptickets/dto/ResetPasswordDto.java new file mode 100644 index 0000000..7eb567f --- /dev/null +++ b/src/main/java/me/gt/snaptickets/dto/ResetPasswordDto.java @@ -0,0 +1,20 @@ +package me.gt.snaptickets.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +@Data +@Builder +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class ResetPasswordDto { + @Schema(description = "帳號") + private String username; + + @Schema(description = "舊密碼") + private String oldPassword; + + @Schema(description = "新密碼") + private String newPassword; +}