Skip to content

Commit e351f76

Browse files
authored
fix(oauth, unlock): 구글 oauth 로그인 취소 시, 리다이렉트 주소 수정 및 근처 공개 캡슐 응답 dto 필드 수정
fix(oauth, unlock): 구글 oauth 로그인 취소 시, 리다이렉트 주소 수정 및 근처 공개 캡슐 응답 dto 필드 수정
2 parents 756f4b7 + d14eb18 commit e351f76

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/main/java/back/fcz/domain/backup/controller/BackupController.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,24 @@ public ResponseEntity<ApiResponse<GoogleDriveConnectionResponse>> capsuleBackup(
5858
"백엔드 서버는 인가 코드를 이용해 연동 토큰을 DB에 저장한 뒤, 프론트엔드 대시보드 페이지로 리다이렉트 합니다.")
5959
@GetMapping("/connect/callback")
6060
public void callback(
61-
@RequestParam String code,
61+
@RequestParam(required = false) String code,
62+
@RequestParam(required = false) String error,
6263
@AuthenticationPrincipal Long memberId,
6364
HttpServletResponse response
6465
) throws IOException {
66+
67+
// 사용자가 권한 허용 취소한 경우
68+
if ("access_denied".equals(error)) {
69+
response.sendRedirect(frontendDomain + "/dashboard/receive");
70+
return;
71+
}
72+
73+
// 에러가 있는 경우
74+
if (error != null) {
75+
response.sendRedirect(frontendDomain + "/dashboard/receive");
76+
return;
77+
}
78+
6579
backupService.saveGoogleToken(memberId, code);
6680
response.sendRedirect(frontendDomain + "/dashboard");
6781
}

src/main/java/back/fcz/domain/unlock/dto/response/NearbyOpenCapsuleResponse.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public record NearbyOpenCapsuleResponse(
1414
String capsuleUnlockType,
1515
double capsuleLatitude,
1616
double capsuleLongitude,
17+
LocalDateTime capsuleUnlockAt,
18+
LocalDateTime capsuleUnlockUntil,
1719

1820
int maxViewCount, // 선착순 제한 인원(NULL이면 무제한)
1921
int currentViewCount, // 현재 조회 인원
@@ -35,6 +37,8 @@ public NearbyOpenCapsuleResponse(Capsule capsule, double distanceToCapsule, bool
3537
capsule.getUnlockType(),
3638
capsule.getLocationLat(),
3739
capsule.getLocationLng(),
40+
capsule.getUnlockAt(),
41+
capsule.getUnlockUntil(),
3842

3943
capsule.getMaxViewCount(),
4044
capsule.getCurrentViewCount(),

src/main/java/back/fcz/global/security/SecurityConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import back.fcz.global.security.filter.JwtAuthenticationFilter;
77
import back.fcz.global.security.oauth.GoogleOAuth2SuccessHandler;
88
import lombok.RequiredArgsConstructor;
9+
import org.springframework.beans.factory.annotation.Value;
910
import org.springframework.context.annotation.Bean;
1011
import org.springframework.context.annotation.Configuration;
1112
import org.springframework.http.HttpMethod;
@@ -29,6 +30,9 @@ public class SecurityConfig {
2930
private final GoogleOAuth2SuccessHandler googleOAuth2SuccessHandler;
3031
private final CustomAuthenticationEntryPoint customAuthenticationEntryPoint;
3132

33+
@Value("${cors.allowed-origins}")
34+
private String frontendDomain;
35+
3236
private static final String[] SWAGGER_WHITELIST = {
3337
"/v3/api-docs/**",
3438
"/swagger-ui/**",
@@ -91,6 +95,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
9195
.oauth2Login(oauth2 -> oauth2
9296
.userInfoEndpoint(userInfo -> userInfo.userService(googleOAuth2Service))
9397
.successHandler(googleOAuth2SuccessHandler)
98+
.failureUrl(frontendDomain + "/auth/login")
9499
)
95100
.exceptionHandling(exception -> exception
96101
.authenticationEntryPoint(customAuthenticationEntryPoint)

0 commit comments

Comments
 (0)