에러 발생 상황
회원 탈퇴 기능 구현 중 기능은 잘 작동하나 탈퇴 후에 인덱스로 리다이렉트 됐을 때 여전히 네비바에 있는 탭이 로그인 시 보여주는 탭으로 보였다.
문제 파악
시큐리티쪽 문제인가 싶어서 검색해보니 탈퇴처리 후 다음 코드를 꼭 추가해야 한다고 한다.
SecurityContextHolder.clearContext();
문제 해결
그래서 위 코드를 회원 탈퇴 service 로직에 추가했더니 이제 회원 탈퇴 후 네비바에 비로그인 상태의 탭이 잘 보인다.
public void delete(UserDeleteRequestDto userDeleteRequestDto) {
User user = userRepository.findById(userDeleteRequestDto.getId()).orElseThrow(() -> new IllegalArgumentException("해당 회원이 존재하지 않습니다."));
if (encoder.matches(userDeleteRequestDto.getPassword(), user.getPassword())) {
userRepository.deleteById(userDeleteRequestDto.getId());
SecurityContextHolder.clearContext();
} else {
throw new IllegalArgumentException("패스워드가 일치하지 않습니다.");
}
}
'오류 로그' 카테고리의 다른 글
org.springframework.web.servlet.PageNotFound - No mapping for GET (0) | 2023.03.02 |
---|---|
스프링 관련된 것들이 모두 에러날 때 (0) | 2022.05.19 |
Ajax done이 실행되지 않음 (0) | 2022.04.01 |
java.lang.IllegalStateException : No primary or single unique constructor found for class [xxx] (0) | 2022.03.11 |
Expected a key while parsing a block mapping (0) | 2022.03.03 |