Skip to content

Commit

Permalink
新增重設密碼API
Browse files Browse the repository at this point in the history
  • Loading branch information
GsTio86 committed Nov 13, 2024
1 parent 46cbf88 commit 5dc418c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,6 +63,12 @@ public ResponseEntity<Object> loginUser(@RequestParam String identifier, @Reques
return ResponseEntity.ok().body(Map.of("username", user.getUsername(), "token", token));
}

@Operation(summary = "重設密碼")
@PutMapping("/auth/reset-password")
public ResponseEntity<String> resetPassword(@RequestBody ResetPasswordDto resetPasswordDto) {
return updatePassword(resetPasswordDto.getUsername(), resetPasswordDto.getOldPassword(), resetPasswordDto.getNewPassword());
}

@Operation(summary = "查詢帳號資料")
@GetMapping("/user/info/{username}")
public ResponseEntity<Object> getUserByUsername(@PathVariable String username) {
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/me/gt/snaptickets/dto/ResetPasswordDto.java
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 5dc418c

Please sign in to comment.