Skip to content

Commit

Permalink
[hotfix] - user 탈퇴시 지역,학교 정리 로직 추가 이전 버전에서 잘못된 점 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
khyojun committed Nov 11, 2024
1 parent 4c6176d commit 4f2987d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/main/java/gitbal/backend/api/auth/service/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
Expand Down Expand Up @@ -102,7 +103,9 @@ private School findSchool(JoinRequestDto joinRequestDto) {
public String withDrawUser(Authentication authentication) {
User user = getAuthenticatedUser(authentication);
try {
withDrawUpdate(user);
userRepository.delete(user);
userService.updateUserRank();
return "성공적으로 탈퇴 처리 되었습니다.";
} catch (Exception e) {
throw new NotDrawUserException();
Expand Down Expand Up @@ -141,20 +144,20 @@ public String logoutUser(String username) {
.orElseThrow(NotFoundUserException::new);
user.setRefreshToken("nothing");
log.info("로그아웃 성공");
logoutUpdateProcess(user);

return "로그아웃에 성공하였습니다.";
}catch (Exception e){
e.printStackTrace();
throw new LogoutException("로그아웃 실패");
}
}

private void logoutUpdateProcess(User user) {
regionService.updatedByLogout(user, user.getRegion());
schoolService.updatedByLogout(user, user.getSchool());
schoolService.updateSchoolRank();
userService.updateUserRank();
private void withDrawUpdate(User user) {
if(Objects.nonNull(user.getRegion()))
regionService.updatedByLogout(user, user.getRegion());
if(Objects.nonNull(user.getSchool())) {
schoolService.updatedByLogout(user, user.getSchool());
schoolService.updateSchoolRank();
}
}

private void updateRank() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ public void updateScore(Region region, Long score) {

public void updatedByLogout(User user, Region region) {
region.minusScore(user.getScore());
log.info("region score {}", region.getScore());
}

}
2 changes: 2 additions & 0 deletions src/main/java/gitbal/backend/domain/school/SchoolService.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ public void updateScore(School school, Long score) {
}

public void updatedByLogout(User user, School school) {
log.info("now this is this");
school.minusScore(user.getScore());
log.info("school score {}", school.getScore());
updateSchoolRank();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
tokenRefresh(githubOAuth2UserInfo);
}
String url = loginService.madeRedirectUrl(githubOAuth2UserInfo.getNickname());


log.info("redirect 보내기 직전");
log.info("redirect url : {}", url);
response.sendRedirect(url);
Expand Down

0 comments on commit 4f2987d

Please sign in to comment.