6
6
import jakarta .servlet .http .HttpServletResponse ;
7
7
import lombok .AllArgsConstructor ;
8
8
import moadong .global .payload .Response ;
9
+ import moadong .global .util .JwtProvider ;
9
10
import moadong .user .annotation .CurrentUser ;
10
11
import moadong .user .payload .CustomUserDetails ;
11
12
import moadong .user .payload .request .UserLoginRequest ;
12
13
import moadong .user .payload .request .UserRegisterRequest ;
13
14
import moadong .user .payload .request .UserUpdateRequest ;
14
15
import moadong .user .payload .response .AccessTokenResponse ;
16
+ import moadong .user .payload .response .FindUserClubResponse ;
17
+ import moadong .user .payload .response .LoginResponse ;
15
18
import moadong .user .service .UserCommandService ;
16
19
import moadong .user .view .UserSwaggerView ;
17
20
import org .springframework .http .ResponseEntity ;
18
21
import org .springframework .security .access .prepost .PreAuthorize ;
22
+ import org .springframework .security .core .annotation .AuthenticationPrincipal ;
19
23
import org .springframework .validation .annotation .Validated ;
20
- import org .springframework .web .bind .annotation .CookieValue ;
21
- import org .springframework .web .bind .annotation .PostMapping ;
22
- import org .springframework .web .bind .annotation .PutMapping ;
23
- import org .springframework .web .bind .annotation .RequestBody ;
24
- import org .springframework .web .bind .annotation .RequestMapping ;
25
- import org .springframework .web .bind .annotation .RestController ;
24
+ import org .springframework .web .bind .annotation .*;
26
25
27
26
@ RestController
28
27
@ RequestMapping ("/auth/user" )
31
30
public class UserController {
32
31
33
32
private final UserCommandService userCommandService ;
33
+ private final JwtProvider jwtProvider ;
34
34
35
35
@ PostMapping ("/register" )
36
36
@ Operation (
@@ -45,8 +45,8 @@ public ResponseEntity<?> registerUser(@RequestBody @Validated UserRegisterReques
45
45
@ PostMapping ("/login" )
46
46
public ResponseEntity <?> loginUser (@ RequestBody @ Validated UserLoginRequest request ,
47
47
HttpServletResponse response ) {
48
- AccessTokenResponse accessTokenResponse = userCommandService .loginUser (request , response );
49
- return Response .ok (accessTokenResponse );
48
+ LoginResponse loginResponse = userCommandService .loginUser (request , response );
49
+ return Response .ok (loginResponse );
50
50
}
51
51
52
52
@ PostMapping ("/refresh" )
@@ -66,4 +66,11 @@ public ResponseEntity<?> update(@CurrentUser CustomUserDetails user,
66
66
return Response .ok ("success update" );
67
67
}
68
68
69
+ @ PostMapping ("/find/club" )
70
+ @ PreAuthorize ("isAuthenticated()" )
71
+ @ SecurityRequirement (name = "BearerAuth" )
72
+ public ResponseEntity <?> findUserClub (@ AuthenticationPrincipal CustomUserDetails userDetails ){
73
+ return Response .ok (new FindUserClubResponse (userDetails .getId ()));
74
+ }
75
+
69
76
}
0 commit comments