Skip to content

Commit

Permalink
Fix duplicate login errors.
Browse files Browse the repository at this point in the history
Signed-off-by: Han Kyuhyun <[email protected]>
Co-authored-by: Jongmin Lee <[email protected]>
Co-authored-by: June Saehwan <[email protected]>
Co-authored-by: ByunJeongHeum <[email protected]>
  • Loading branch information
4 people committed Sep 15, 2023
1 parent b818268 commit 81f3ad5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/lpvs/entity/LPVSMember.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@Getter @NoArgsConstructor
@DynamicUpdate
@Entity
@Table(name = "member")
@Table(name = "member", uniqueConstraints = @UniqueConstraint(columnNames = {"email", "provider"}))
public class LPVSMember {

@Id
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/com/lpvs/service/LPVSLoginCheckService.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ public LPVSMember getMemberFromMemberMap(Authentication authentication) {
if (findMemberOptional.isPresent()) {
return findMemberOptional.get();
} else {
LPVSMember newMember = new LPVSMember();
newMember.setJoin(name, email, provider);
memberRepository.save(newMember);
return newMember;
synchronized (this) {
findMemberOptional = memberRepository.findByEmailAndProvider(email, provider);
if (findMemberOptional.isPresent()) {
return findMemberOptional.get();
} else {
LPVSMember newMember = new LPVSMember();
newMember.setJoin(name, email, provider);
memberRepository.save(newMember);
return newMember;
}
}
}
}
}

0 comments on commit 81f3ad5

Please sign in to comment.