-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ refactor: 사용자 중복 OAuth 로그인 검증 로직 추가 (#52)
- Loading branch information
Showing
3 changed files
with
104 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/slvtwn/khu/toyouserver/domain/UserSocialAccount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package slvtwn.khu.toyouserver.domain; | ||
|
||
|
||
import static jakarta.persistence.GenerationType.IDENTITY; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Table(name = "user_social_accounts") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
public class UserSocialAccount { | ||
|
||
@Id | ||
@GeneratedValue(strategy = IDENTITY) | ||
private Long id; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private SocialAuthProvider provider; | ||
private String providerSerial; | ||
private Long userId; | ||
|
||
public static UserSocialAccount createAccountByKakao(Long userId, String providerSerial) { | ||
return new UserSocialAccount(null, SocialAuthProvider.KAKAO, providerSerial, userId); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/slvtwn/khu/toyouserver/persistance/UserSocialAccountRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package slvtwn.khu.toyouserver.persistance; | ||
|
||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import slvtwn.khu.toyouserver.domain.UserSocialAccount; | ||
|
||
public interface UserSocialAccountRepository extends JpaRepository<UserSocialAccount, Long> { | ||
Optional<UserSocialAccount> findByProviderSerial(String providerSerial); | ||
} |