-
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.
Browse files
Browse the repository at this point in the history
[#57] 탈퇴 후 재로그인 문제 수정
- Loading branch information
Showing
15 changed files
with
224 additions
and
90 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
9 changes: 9 additions & 0 deletions
9
src/main/java/com/dnd/dndtravel/auth/controller/request/ReIssueTokenRequest.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 |
---|---|---|
@@ -1,6 +1,15 @@ | ||
package com.dnd.dndtravel.auth.controller.request; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public record ReIssueTokenRequest( | ||
@Schema(description = "mapddang refresh token", requiredMode = REQUIRED) | ||
@NotBlank(message = "refresh token은 필수 입니다.") | ||
@Size(max = 300, message = "refresh token 형식이 아닙니다.") | ||
String refreshToken | ||
) { | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/dnd/dndtravel/auth/exception/RequireReAuthenticationException.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 com.dnd.dndtravel.auth.exception; | ||
|
||
public class RequireReAuthenticationException extends RuntimeException { | ||
private static final String MESSAGE = "Apple 계정 재인증이 필요합니다."; | ||
|
||
public RequireReAuthenticationException(Exception e) { | ||
super(MESSAGE, e); | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
src/main/java/com/dnd/dndtravel/auth/service/AuthService.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,39 @@ | ||
package com.dnd.dndtravel.auth.service; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import com.dnd.dndtravel.auth.service.dto.response.AppleTokenResponse; | ||
import com.dnd.dndtravel.auth.service.dto.response.TokenResponse; | ||
import com.dnd.dndtravel.member.domain.Member; | ||
import com.dnd.dndtravel.member.service.MemberService; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class AuthService { | ||
private final AppleOAuthService appleOAuthService; | ||
private final MemberService memberService; | ||
private final JwtTokenService jwtTokenService; | ||
|
||
public Optional<TokenResponse> processAppleLogin(String authorizationCode, String selectedColor) { | ||
AppleTokenResponse appleToken = appleOAuthService.get(authorizationCode); | ||
|
||
Member member = memberService.saveMember( | ||
appleToken.email(), | ||
appleToken.sub(), | ||
selectedColor | ||
); | ||
|
||
return Optional.ofNullable( | ||
jwtTokenService.generateTokens(member.getId(), appleToken.appleRefreshToken()) | ||
); | ||
} | ||
|
||
public void processAppleRevoke(String refreshToken, long memberId) { | ||
appleOAuthService.revoke(refreshToken); | ||
memberService.withdrawMember(memberId); | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
src/main/java/com/dnd/dndtravel/auth/service/dto/response/AppleTokenResponse.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,17 @@ | ||
package com.dnd.dndtravel.auth.service.dto.response; | ||
|
||
public record AppleTokenResponse( | ||
String sub, | ||
String name, | ||
String email, | ||
String appleRefreshToken | ||
) { | ||
public static AppleTokenResponse of(AppleIdTokenPayload appleIdTokenPayload, String appleRefreshToken) { | ||
return new AppleTokenResponse( | ||
appleIdTokenPayload.sub(), | ||
appleIdTokenPayload.name(), | ||
appleIdTokenPayload.email(), | ||
appleRefreshToken | ||
); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/dnd/dndtravel/map/repository/WithdrawMemberRepository.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,11 @@ | ||
package com.dnd.dndtravel.map.repository; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.dnd.dndtravel.member.domain.WithdrawMember; | ||
|
||
public interface WithdrawMemberRepository extends JpaRepository<WithdrawMember, Long> { | ||
Optional<WithdrawMember> findByAppleId(String sub); | ||
} |
Oops, something went wrong.