-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from YAPP-Github/feature/PC-582-logout
[PC-582] 로그아웃 기능 구현
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
api/src/main/java/org/yapp/domain/auth/application/oauth/service/LogoutService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.yapp.domain.auth.application.oauth.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.yapp.core.auth.token.RefreshTokenService; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class LogoutService { | ||
|
||
private final RefreshTokenService refreshTokenService; | ||
|
||
public void logout(Long userId) { | ||
refreshTokenService.deleteRefreshToken(userId); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
api/src/main/java/org/yapp/domain/auth/presentation/LogoutController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.yapp.domain.auth.presentation; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.yapp.domain.auth.application.oauth.service.LogoutService; | ||
import org.yapp.format.CommonResponse; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/logout") | ||
public class LogoutController { | ||
|
||
private final LogoutService logoutService; | ||
|
||
@PatchMapping | ||
public ResponseEntity<CommonResponse<Void>> logout(@AuthenticationPrincipal Long userId) { | ||
logoutService.logout(userId); | ||
return ResponseEntity.ok(CommonResponse.createSuccessWithNoContent()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters