Skip to content

Conversation

@Uralauah
Copy link
Contributor

게스트 회원 전환 로직 작성

📝 개요

게스트 회원 전환 로직 작성


⚙️ 구현 내용

게스트가 회원으로 전환할 때, 게스트 계정으로 플레이했던 정보를 그대로 회원으로 전환하기 위한 기능을 구현하였습니다.
현재는 User 엔티티에 경험치, 레벨과 같은 정보가 추가되어있지 않아서 아래의 두 로직에 차이가 없지만 해당 부분이 생긴다면 기존의 정보를 옮기는 방식으로 수정할 계획입니다.

public User toEntity(String encodePassword) {
        return User.builder()
                .email(email)
                .password(encodePassword)
                .nickname(nickname)
                .role(Role.USER)
                .build();
    }

    public User toEntityFromGuest(String encodePassword, User guest){
        return User.builder()
                .email(email)
                .password(encodePassword)
                .nickname(nickname)
                .role(Role.USER)
                .build();
    }

기존에 인증 과정에서 토큰에 포함된 사용자 정보가 실제 존재하지 않는 경우
(예: 게스트 → 회원 전환, 탈퇴한 회원 등), UsernameNotFoundException 예외가 발생했지만
이를 처리하지 않아 500 에러가 반환되는 문제가 있었습니다.

JwtAuthenticationFilter에서 해당 예외를 catch 하여
적절한 인증 실패 응답을 반환하도록 수정했습니다.


@Uralauah Uralauah requested review from brothergiven and jung-min-ju and removed request for jung-min-ju April 14, 2025 09:46
if (!fieldErrors.isEmpty()) {
throw new FieldValidationException(fieldErrors);
}
System.out.println(guestId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요 라인 지우는걸 깜빡하신 것 같습니다 ! !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헉 맞네요!

Copy link
Contributor

@brothergiven brothergiven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다👍👍👍

@Uralauah Uralauah requested a review from jung-min-ju April 16, 2025 07:18
Copy link
Contributor

@jung-min-ju jung-min-ju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

모두 확인했습니다! 전체적으로 에러처리도 잘 되어있는 것 같습니다. 한 가지 말하자면 하드 코딩이 되어 있는 곳이 종종 보인다는 건데, 이건 추후 수정해도 괜찮을 듯 합니다.

@Uralauah Uralauah merged commit 4bd7c14 into develop Apr 19, 2025
1 check passed
@Uralauah Uralauah deleted the feat/auth branch April 19, 2025 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants