-
Notifications
You must be signed in to change notification settings - Fork 1
feat: 애플 회원탈퇴 구현 완료 #76
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
Changes from all commits
64c1778
2b3eb9b
928fa72
ec35923
26b1e99
db107b2
83e22f2
ad2de11
fe59f9a
37c905d
44154b6
f41a03e
c4581b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package org.yapp.apis.auth.dto.request | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema | ||
| import jakarta.validation.constraints.NotBlank | ||
| import jakarta.validation.constraints.NotNull | ||
| import org.yapp.domain.user.ProviderType | ||
|
|
||
| @Schema( | ||
| name = "WithdrawRequest", | ||
| description = "DTO for user withdrawal requests" | ||
| ) | ||
| data class WithdrawRequest private constructor( | ||
| @Schema( | ||
| description = "Type of social login provider for withdrawal", | ||
| example = "APPLE", | ||
| required = true | ||
| ) | ||
| @field:NotNull(message = "Provider type is not-null") | ||
| val providerType: ProviderType? = null | ||
| ) { | ||
| fun validProviderType(): ProviderType = providerType!! | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package org.yapp.apis.auth.dto.request | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema | ||
| import org.yapp.apis.user.dto.response.WithdrawTargetUserResponse | ||
| import org.yapp.domain.user.ProviderType | ||
| import java.util.* | ||
|
|
||
| @Schema(description = "회원 탈퇴 처리 시 내부적으로 사용되는 요청 DTO") | ||
| data class WithdrawStrategyRequest private constructor( | ||
| @Schema( | ||
| description = "사용자 고유 ID", | ||
| example = "123e4567-e89b-12d3-a456-426614174000", | ||
| ) | ||
| val userId: UUID, | ||
|
|
||
| @Schema( | ||
| description = "소셜 로그인 제공자 타입", | ||
| example = "KAKAO", | ||
| ) | ||
| val providerType: ProviderType, | ||
|
|
||
| @Schema( | ||
| description = "소셜 로그인 제공자로부터 발급받은 고유 ID", | ||
| example = "21412412412", | ||
| ) | ||
| val providerId: String, | ||
|
|
||
| @Schema( | ||
| description = "Apple 로그인 시 발급받은 리프레시 토큰 (Apple 로그인 회원 탈퇴 시에만 필요)", | ||
| example = "r_abc123def456ghi789jkl0mnopqrstu", | ||
| required = false | ||
| ) | ||
| val appleRefreshToken: String? | ||
| ) { | ||
| companion object { | ||
| fun from(response: WithdrawTargetUserResponse): WithdrawStrategyRequest { | ||
| return WithdrawStrategyRequest( | ||
| userId = response.id, | ||
| providerType = response.providerType, | ||
| providerId = response.providerId, | ||
| appleRefreshToken = response.appleRefreshToken | ||
| ) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,28 +1,23 @@ | ||||||||||||||||||||||||||||||||||||
| package org.yapp.apis.auth.service | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| import jakarta.validation.Valid | ||||||||||||||||||||||||||||||||||||
| import org.springframework.stereotype.Service | ||||||||||||||||||||||||||||||||||||
| import org.springframework.validation.annotation.Validated | ||||||||||||||||||||||||||||||||||||
| import org.yapp.apis.auth.dto.request.SaveAppleRefreshTokenRequest | ||||||||||||||||||||||||||||||||||||
| import org.yapp.apis.auth.exception.AuthErrorCode | ||||||||||||||||||||||||||||||||||||
| import org.yapp.apis.auth.exception.AuthException | ||||||||||||||||||||||||||||||||||||
| import org.yapp.apis.auth.manager.AppleApiManager | ||||||||||||||||||||||||||||||||||||
| import org.yapp.domain.user.UserDomainService | ||||||||||||||||||||||||||||||||||||
| import org.yapp.infra.external.oauth.apple.response.AppleTokenResponse | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| @Service | ||||||||||||||||||||||||||||||||||||
| @Validated | ||||||||||||||||||||||||||||||||||||
| class AppleAuthService( | ||||||||||||||||||||||||||||||||||||
| private val appleApiManager: AppleApiManager, | ||||||||||||||||||||||||||||||||||||
| private val userDomainService: UserDomainService | ||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||
| fun saveAppleRefreshTokenIfMissing(@Valid request: SaveAppleRefreshTokenRequest) { | ||||||||||||||||||||||||||||||||||||
| if (request.appleRefreshToken == null) { | ||||||||||||||||||||||||||||||||||||
| val tokenResponse = appleApiManager.fetchAppleOauthTokens(request.validAuthorizationCode()) | ||||||||||||||||||||||||||||||||||||
| fun fetchAppleOauthTokens(authorizationCode: String): AppleTokenResponse { | ||||||||||||||||||||||||||||||||||||
| val tokenResponse = appleApiManager.fetchAppleOauthTokens(authorizationCode) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| val refreshToken = tokenResponse.refreshToken | ||||||||||||||||||||||||||||||||||||
| ?: throw AuthException(AuthErrorCode.MISSING_APPLE_REFRESH_TOKEN) | ||||||||||||||||||||||||||||||||||||
| tokenResponse.refreshToken | ||||||||||||||||||||||||||||||||||||
| ?: throw AuthException(AuthErrorCode.MISSING_APPLE_REFRESH_TOKEN) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| userDomainService.updateAppleRefreshToken(request.validUserId(), refreshToken) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| return tokenResponse | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) 불필요한 null 체크 로직 간소화 가능
fun fetchAppleOauthTokens(authorizationCode: String): AppleTokenResponse {
- val tokenResponse = appleApiManager.fetchAppleOauthTokens(authorizationCode)
-
- tokenResponse.refreshToken
- ?: throw AuthException(AuthErrorCode.MISSING_APPLE_REFRESH_TOKEN)
-
- return tokenResponse
+ return appleApiManager.fetchAppleOauthTokens(authorizationCode).also {
+ it.refreshToken ?: throw AuthException(AuthErrorCode.MISSING_APPLE_REFRESH_TOKEN)
+ }
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package org.yapp.apis.auth.service | ||
|
|
||
| import jakarta.validation.Valid | ||
| import org.springframework.stereotype.Service | ||
| import org.springframework.transaction.annotation.Transactional | ||
| import org.yapp.apis.user.dto.request.FindOrCreateUserRequest | ||
| import org.yapp.apis.user.dto.response.CreateUserResponse | ||
| import org.yapp.apis.user.service.UserAccountService | ||
|
|
||
| @Service | ||
| class UserSignInService( | ||
| private val userAccountService: UserAccountService, | ||
| ) { | ||
| @Transactional | ||
| fun processSignIn( | ||
| @Valid request: FindOrCreateUserRequest, | ||
| appleRefreshToken: String? | ||
| ): CreateUserResponse { | ||
| val createUserResponse = userAccountService.findOrCreateUser(request) | ||
|
|
||
| appleRefreshToken?.let { | ||
| userAccountService.updateAppleRefreshToken(createUserResponse.id, it) | ||
| } | ||
|
|
||
| return createUserResponse | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.