Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ› OAuth 계정 연동 μ‹€νŒ¨ #42

Closed
psychology50 opened this issue Apr 11, 2024 · 0 comments
Closed

πŸ› OAuth 계정 연동 μ‹€νŒ¨ #42

psychology50 opened this issue Apr 11, 2024 · 0 comments
Assignees
Labels
bug κΈ΄κΈ‰ν•˜κ³ , μ€‘μš”λ„κ°€ 높은 이슈

Comments

@psychology50
Copy link
Member

버그 λ‚΄μš©

  • [4-1] 계정 μ—°λ™μ—μ„œ Entityκ°€ λ§€ν•‘λ˜μ§€ μ•Šμ•„ OAuth 정보가 ν…Œμ΄λΈ”μ— λ°˜μ˜λ˜μ§€ μ•ŠμŒ.

버그 μœ„μΉ˜

@Mapper
@RequiredArgsConstructor
public class UserOauthSignMapper {
    ...

    /**
     * κΈ°μ‘΄ 계정이 μ‘΄μž¬ν•˜λ©΄ Oauth 계정을 μƒμ„±ν•˜μ—¬ μ—°λ™ν•˜κ³ , μ‘΄μž¬ν•˜μ§€ μ•ŠμœΌλ©΄ μƒˆλ‘œμš΄ 계정을 μƒμ„±ν•œλ‹€.
     *
     * @param request {@link SignUpReq.OauthInfo}
     */
    @Transactional
    public User saveUser(SignUpReq.OauthInfo request, Pair<Boolean, String> isSignUpUser, Provider provider, String oauthId) {
        User user;

        if (isSignUpUser.getLeft().equals(Boolean.TRUE)) {
            user = userService.readUserByUsername(isSignUpUser.getRight())
                    .orElseThrow(() -> new UserErrorException(UserErrorCode.NOT_FOUND));
            Oauth.of(provider, oauthId, user);
        } else {
            user = User.builder()
                    .username(request.username())
                    .name(request.name())
                    .phone(request.phone())
                    .role(Role.USER)
                    .profileVisibility(ProfileVisibility.PUBLIC).build();
            userService.createUser(user);
            Oauth.of(provider, oauthId, user);
        }

        return user;
    }
}
  • μ•„λ§ˆλ„ μ˜μ†ν™”λœ User entityμ—μ„œ Oauth 정보λ₯Ό 맀핑해주지 μ•ŠμœΌλ©΄μ„œ, OauthService.save()도 해주지 μ•ŠκΈ° λ•Œλ¬Έμ΄λΌκ³  μΆ”μΈ‘

μž¬ν˜„

  • iOS μš”μ²­μ΄ μžˆμ–΄μ•Ό ν•΄μ„œ μž¬ν˜„μ€ λΆˆκ°€ν•˜μ§€λ§Œ, 회의λ₯Ό ν†΅ν•΄μ„œ λ ˆμ½”λ“œκ°€ κ°±μ‹ λ˜μ§€ μ•ŠμŒμ„ 확인.

할일

  • User entity에 List<Oauth>λ₯Ό κ΄€λ¦¬ν•˜μ—¬ 연관관계 λ„μš°λ―Έ λ©”μ„œλ“œλ₯Ό ν˜ΈμΆœν•˜λ„λ‘ μˆ˜μ •
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug κΈ΄κΈ‰ν•˜κ³ , μ€‘μš”λ„κ°€ 높은 이슈
Projects
None yet
Development

No branches or pull requests

1 participant