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

Github UserName 변경 시 Update가 아닌 새로운 User 삽입 #23

Open
ghost opened this issue Jun 26, 2020 · 0 comments
Open

Github UserName 변경 시 Update가 아닌 새로운 User 삽입 #23

ghost opened this issue Jun 26, 2020 · 0 comments
Assignees
Labels
🧨 Bug 버그 발생

Comments

@ghost
Copy link

ghost commented Jun 26, 2020

작업 내용

Github UserName 변경 시 Update가 아닌 새로운 User 삽입

	private User saveOrUpdate(OAuthAttributes attributes) {
        User user = userRepository.findByName(attributes.getName())
                .map(entity -> entity.update(attributes.getEmail(), attributes.getPicture()))
                .orElse(attributes.toEntity());

        return userRepository.save(user);
    }

아래는 github 로그인 Response 값들이다.

"login" -> "slowCoyle"
"id" -> {Integer@10964} 34959979
"node_id" -> "MDQ6VXNlcjM0OTU5OTc5"
"avatar_url" -> "https://avatars2.githubusercontent.com/u/34959979?v=4"
"gravatar_id" -> ""
"url" -> "https://api.github.com/users/slowCoyle"
"html_url" -> "https://github.com/slowCoyle"
"followers_url" -> "https://api.github.com/users/slowCoyle/followers"
"following_url" -> "https://api.github.com/users/slowCoyle/following{/other_user}"
"gists_url" -> "https://api.github.com/users/slowCoyle/gists{/gist_id}"
"starred_url" -> "https://api.github.com/users/slowCoyle/starred{/owner}{/repo}"
"subscriptions_url" -> "https://api.github.com/users/slowCoyle/subscriptions"
"organizations_url" -> "https://api.github.com/users/slowCoyle/orgs"
"repos_url" -> "https://api.github.com/users/slowCoyle/repos"
"events_url" -> "https://api.github.com/users/slowCoyle/events{/privacy}"
"received_events_url" -> "https://api.github.com/users/slowCoyle/received_events"
"type" -> "User"
"site_admin" -> {Boolean@10996} false
"name" -> "coyle"
"company" -> null
"blog" -> "https://slowcoyle.github.io/"
"location" -> null
"email" -> null
"hireable" -> null
"bio" -> null
"twitter_username" -> null
"public_repos" -> {Integer@11007} 49
"public_gists" -> {Integer@11009} 0
"followers" -> {Integer@11011} 29
"following" -> {Integer@11013} 26
"created_at" -> "2017-12-30T11:34:19Z"
"updated_at" -> "2020-06-26T02:30:48Z"
"private_gists" -> {Integer@11009} 0
"total_private_repos" -> {Integer@11020} 1
"owned_private_repos" -> {Integer@11020} 1
"disk_usage" -> {Integer@11023} 316886
"collaborators" -> {Integer@11009} 0
"two_factor_authentication" -> {Boolean@10996} false
"plan" -> {LinkedHashMap@11027}  size = 4

userName을 기준으로 user를 찾고 update를 수행하는데 github에서 username을 변경하면 내 DB와 동기화가 되어있지 않아 새롭게 들어온 User로 판단하고 userRepository.save를 수행하게된다.

이를 해결하는 방법이 없을까 ?

주의사항

@ghost ghost added the 🧨 Bug 버그 발생 label Jun 26, 2020
@ghost ghost assigned pci2676, YebinK and ghost Jun 26, 2020
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

2 participants