|
2 | 2 |
|
3 | 3 | import backend.capstone.auth.dto.KakaoLoginRequest; |
4 | 4 | import backend.capstone.auth.dto.LoginResponse; |
5 | | -import backend.capstone.auth.jwt.service.JwtTokenProvider; |
| 5 | +import backend.capstone.auth.dto.TokenPair; |
6 | 6 | import backend.capstone.auth.service.AuthService; |
7 | 7 | import lombok.RequiredArgsConstructor; |
8 | 8 | import org.springframework.http.HttpStatus; |
9 | 9 | import org.springframework.web.bind.annotation.GetMapping; |
10 | 10 | import org.springframework.web.bind.annotation.PostMapping; |
11 | 11 | import org.springframework.web.bind.annotation.RequestBody; |
| 12 | +import org.springframework.web.bind.annotation.RequestHeader; |
12 | 13 | import org.springframework.web.bind.annotation.RequestMapping; |
13 | 14 | import org.springframework.web.bind.annotation.ResponseStatus; |
14 | 15 | import org.springframework.web.bind.annotation.RestController; |
15 | 16 |
|
16 | 17 | @RestController |
17 | 18 | @RequestMapping("/api/auth") |
18 | 19 | @RequiredArgsConstructor |
19 | | -public class AuthController { |
| 20 | +public class AuthController implements AuthControllerSpec { |
20 | 21 |
|
21 | | - private final AuthService authService; |
22 | | - private final JwtTokenProvider jwtTokenProvider; |
| 22 | + private final AuthService authService; |
23 | 23 |
|
24 | | - @PostMapping("/login/kakao") |
25 | | - @ResponseStatus(HttpStatus.CREATED) |
26 | | - public LoginResponse kakaoLogin(@RequestBody KakaoLoginRequest request) { |
27 | | - return authService.kakaoLogin(request.kakaoAccessToken()); |
28 | | - } |
| 24 | + @Override |
| 25 | + @PostMapping("/login/kakao") |
| 26 | + @ResponseStatus(HttpStatus.CREATED) |
| 27 | + public LoginResponse kakaoLogin(@RequestBody KakaoLoginRequest request) { |
| 28 | + return authService.kakaoLogin(request.kakaoAccessToken()); |
| 29 | + } |
29 | 30 |
|
30 | | - @GetMapping("/test") |
31 | | - public String issueTestJwt() { |
32 | | - return jwtTokenProvider.createAccessToken(1L); |
33 | | - } |
| 31 | + @Override |
| 32 | + @PostMapping("/refresh") |
| 33 | + @ResponseStatus(HttpStatus.CREATED) |
| 34 | + public TokenPair refresh(@RequestHeader(value = "X-Refresh-Token") String refreshToken) { |
| 35 | + return authService.refreshAccessToken(refreshToken); |
| 36 | + } |
| 37 | + |
| 38 | + @Override |
| 39 | + @GetMapping("/test-issue") |
| 40 | + public TokenPair issueTestJwt() { |
| 41 | + return authService.testIssue(); |
| 42 | + } |
34 | 43 |
|
35 | 44 | } |
0 commit comments