-
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.
- Loading branch information
1 parent
59aac1d
commit d0e63a7
Showing
8 changed files
with
92 additions
and
58 deletions.
There are no files selected for viewing
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
9 changes: 9 additions & 0 deletions
9
src/main/java/com/kakaoteck/golagola/domain/auth/Repository/UserRepository.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
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
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
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
87 changes: 47 additions & 40 deletions
87
...ain/java/com/kakaoteck/golagola/security/handler/signout/CustomSignOutProcessHandler.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 |
---|---|---|
@@ -1,40 +1,47 @@ | ||
//package com.kakaoteck.golagola.security.handler.signout; | ||
// | ||
// | ||
//import jakarta.servlet.http.HttpServletRequest; | ||
//import jakarta.servlet.http.HttpServletResponse; | ||
//import jakarta.transaction.Transactional; | ||
//import lombok.RequiredArgsConstructor; | ||
//import lombok.extern.slf4j.Slf4j; | ||
//import org.springframework.security.core.Authentication; | ||
//import org.springframework.security.web.authentication.logout.LogoutHandler; | ||
//import org.springframework.stereotype.Component; | ||
// | ||
//@Component | ||
//@RequiredArgsConstructor | ||
//@Slf4j | ||
//public class CustomSignOutProcessHandler implements LogoutHandler { | ||
//// private final UserRepository userRepository; | ||
//// | ||
//// @Override | ||
//// @Transactional | ||
//// public void logout(HttpServletRequest request, HttpServletResponse response, | ||
//// Authentication authentication) { | ||
//// if (authentication == null) { | ||
//// return; | ||
//// } | ||
//// | ||
//// CustomUserDetails userPrincipal = (CustomUserDetails) authentication.getPrincipal(); | ||
//// | ||
//// userRepository.updateRefreshTokenAndLoginStatus(userPrincipal.getId(), null, false); | ||
//// } | ||
// | ||
// | ||
//} | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
// | ||
package com.kakaoteck.golagola.security.handler.signout; | ||
|
||
|
||
import com.kakaoteck.golagola.domain.auth.Repository.UserRepository; | ||
import com.kakaoteck.golagola.domain.auth.dto.CustomOAuth2User; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import jakarta.transaction.Transactional; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.web.authentication.logout.LogoutHandler; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class CustomSignOutProcessHandler implements LogoutHandler { | ||
private final UserRepository userRepository; | ||
|
||
@Override | ||
@Transactional | ||
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { | ||
if (authentication == null) { | ||
return; | ||
} | ||
|
||
// 1. 테리코드 | ||
// CustomUserDetails userPrincipal = (CustomUserDetails) authentication.getPrincipal(); | ||
// userRepository.updateRefreshTokenAndLoginStatus(userPrincipal.getId(), null, false); | ||
|
||
// 2. 용우코드 | ||
CustomOAuth2User userPrincipal = (CustomOAuth2User) authentication.getPrincipal(); // CustomOAuth2User 사용 | ||
System.out.println("로그아웃 정보 확인"+ userPrincipal + userPrincipal.getUsername()); | ||
userRepository.updateRefreshTokenAndLoginStatus(userPrincipal.getUsername(), null, false); // UserEntity에서 해당 유저를 찾아서 리프레시 토큰과 로그인 상태를 업데이트 | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
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
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