File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
src/main/java/com/likelion/ai_teacher_a/domain/user Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 22
33import org .springframework .http .ResponseEntity ;
44import org .springframework .web .bind .annotation .DeleteMapping ;
5+ import org .springframework .web .bind .annotation .PostMapping ;
56import org .springframework .web .bind .annotation .RequestMapping ;
67import org .springframework .web .bind .annotation .RestController ;
78
@@ -28,4 +29,10 @@ public ResponseEntity<Void> deleteCurrentUser(@LoginUserId Long loginId) {
2829 return ResponseEntity .noContent ().build ();
2930 }
3031
32+ @ PostMapping ("/logout" )
33+ public ResponseEntity <?> logout (@ LoginUserId Long userId ) {
34+ userService .deleteRefreshToken (userId );
35+ return ResponseEntity .ok ().build ();
36+ }
37+
3138}
Original file line number Diff line number Diff line change @@ -35,5 +35,13 @@ public void deleteUserById(Long id) {
3535
3636 userRepository .deleteById (user .getId ());
3737 }
38+
39+ @ Transactional
40+ public void deleteRefreshToken (Long userId ) {
41+ User user = userRepository .findById (userId )
42+ .orElseThrow (() -> new CustomException (ErrorCode .USER_NOT_FOUND ));
43+ user .setRefreshToken (null );
44+
45+ }
3846}
3947
You can’t perform that action at this time.
0 commit comments