-
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.
Merge pull request #242 from TeamDilly/develop
v1.5.1
- Loading branch information
Showing
65 changed files
with
1,001 additions
and
378 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
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
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
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
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
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
60 changes: 60 additions & 0 deletions
60
packy-api/src/main/java/com/dilly/auth/application/strategy/AppleStrategy.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,60 @@ | ||
package com.dilly.auth.application.strategy; | ||
|
||
import com.dilly.auth.adaptor.AppleAccountReader; | ||
import com.dilly.auth.adaptor.AppleAccountWriter; | ||
import com.dilly.auth.application.AppleService; | ||
import com.dilly.auth.domain.AppleAccount; | ||
import com.dilly.auth.dto.request.SignupRequest; | ||
import com.dilly.auth.model.AppleAccountInfo; | ||
import com.dilly.auth.model.AppleToken; | ||
import com.dilly.member.adaptor.MemberWriter; | ||
import com.dilly.member.domain.Member; | ||
import com.dilly.member.domain.ProfileImage; | ||
import com.dilly.member.domain.Provider; | ||
import java.util.Optional; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class AppleStrategy implements AuthStrategy { | ||
|
||
private final AppleService appleService; | ||
|
||
private final MemberWriter memberWriter; | ||
private final AppleAccountReader appleAccountReader; | ||
private final AppleAccountWriter appleAccountWriter; | ||
|
||
@Override | ||
public Member signUp(String providerAccessToken, SignupRequest signupRequest, ProfileImage profileImage) { | ||
AppleToken appleToken = appleService.getAppleToken(providerAccessToken); | ||
AppleAccountInfo appleAccountInfo = appleService.getAppleAccountInfo(appleToken.idToken()); | ||
appleAccountReader.isAppleAccountPresent(appleAccountInfo.sub()); | ||
|
||
Member member = memberWriter.save(signupRequest.toMember(Provider.APPLE, profileImage)); | ||
appleAccountWriter.save(AppleAccount.builder() | ||
.id(appleAccountInfo.sub()) | ||
.member(member) | ||
.refreshToken(appleToken.refreshToken()) | ||
.build() | ||
); | ||
|
||
return member; | ||
} | ||
|
||
@Override | ||
public Optional<Member> signIn(String providerAccessToken) { | ||
AppleAccountInfo appleAccountInfo = appleService.getAppleAccountInfo( | ||
providerAccessToken); | ||
|
||
return appleAccountReader.getMemberById(appleAccountInfo.sub()); | ||
} | ||
|
||
@Override | ||
public void withdraw(Member member) { | ||
AppleAccount appleAccount = appleAccountReader.findByMember(member); | ||
|
||
appleService.revokeAppleAccount(appleAccount); | ||
appleAccountWriter.delete(appleAccount); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
packy-api/src/main/java/com/dilly/auth/application/strategy/AuthActionProvider.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,27 @@ | ||
package com.dilly.auth.application.strategy; | ||
|
||
import com.dilly.member.domain.Provider; | ||
import java.util.EnumMap; | ||
import java.util.Map; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class AuthActionProvider { | ||
|
||
private final Map<Provider, AuthStrategy> authActions; | ||
|
||
public AuthActionProvider( | ||
final KakaoStrategy kakaoStrategy, | ||
final AppleStrategy appleStrategy, | ||
final TestStrategy testStrategy | ||
) { | ||
this.authActions = new EnumMap<>(Provider.class); | ||
this.authActions.put(Provider.KAKAO, kakaoStrategy); | ||
this.authActions.put(Provider.APPLE, appleStrategy); | ||
this.authActions.put(Provider.TEST, testStrategy); | ||
} | ||
|
||
public AuthStrategy getStrategy(Provider provider) { | ||
return authActions.get(provider); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packy-api/src/main/java/com/dilly/auth/application/strategy/AuthStrategy.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,13 @@ | ||
package com.dilly.auth.application.strategy; | ||
|
||
import com.dilly.auth.dto.request.SignupRequest; | ||
import com.dilly.member.domain.Member; | ||
import com.dilly.member.domain.ProfileImage; | ||
import java.util.Optional; | ||
|
||
public interface AuthStrategy { | ||
|
||
Member signUp(String providerAccessToken, SignupRequest signupRequest, ProfileImage profileImage); | ||
Optional<Member> signIn(String providerAccessToken); | ||
void withdraw(Member member); | ||
} |
53 changes: 53 additions & 0 deletions
53
packy-api/src/main/java/com/dilly/auth/application/strategy/KakaoStrategy.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,53 @@ | ||
package com.dilly.auth.application.strategy; | ||
|
||
import com.dilly.auth.adaptor.KakaoAccountReader; | ||
import com.dilly.auth.adaptor.KakaoAccountWriter; | ||
import com.dilly.auth.application.KakaoService; | ||
import com.dilly.auth.domain.KakaoAccount; | ||
import com.dilly.auth.dto.request.SignupRequest; | ||
import com.dilly.auth.model.KakaoResource; | ||
import com.dilly.member.adaptor.MemberWriter; | ||
import com.dilly.member.domain.Member; | ||
import com.dilly.member.domain.ProfileImage; | ||
import com.dilly.member.domain.Provider; | ||
import java.util.Optional; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class KakaoStrategy implements AuthStrategy { | ||
|
||
private final KakaoService kakaoService; | ||
|
||
private final MemberWriter memberWriter; | ||
private final KakaoAccountReader kakaoAccountReader; | ||
private final KakaoAccountWriter kakaoAccountWriter; | ||
|
||
@Override | ||
public Member signUp(String providerAccessToken, SignupRequest signupRequest, ProfileImage profileImage) { | ||
|
||
KakaoResource kakaoResource = kakaoService.getKaKaoAccount(providerAccessToken); | ||
kakaoAccountReader.isKakaoAccountPresent(kakaoResource.getId()); | ||
|
||
Member member = memberWriter.save(signupRequest.toMember(Provider.KAKAO, profileImage)); | ||
kakaoAccountWriter.save(kakaoResource.toMember(member)); | ||
|
||
return member; | ||
} | ||
|
||
@Override | ||
public Optional<Member> signIn(String providerAccessToken) { | ||
KakaoResource kakaoResource = kakaoService.getKaKaoAccount(providerAccessToken); | ||
|
||
return kakaoAccountReader.getMemberById(kakaoResource.getId()); | ||
} | ||
|
||
@Override | ||
public void withdraw(Member member) { | ||
KakaoAccount kakaoAccount = kakaoAccountReader.findByMember(member); | ||
|
||
kakaoService.unlinkKakaoAccount(kakaoAccount); | ||
kakaoAccountWriter.delete(kakaoAccount); | ||
} | ||
} |
Oops, something went wrong.