Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ public class CustomOAuthFailureHandler extends SimpleUrlAuthenticationFailureHan
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) {
// TODO 프론트엔드와 협의
log.error("안녕 난 말하는 감자야");
log.error(exception.getMessage());
log.error(exception.getCause().getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.somemore.volunteer.service;
package com.somemore.auth.signout.service;

import com.somemore.auth.cookie.CookieUseCase;
import com.somemore.auth.jwt.refresh.manager.RefreshTokenManager;
import com.somemore.volunteer.usecase.SignOutVolunteerUseCase;
import com.somemore.auth.signout.usecase.SignOutUseCase;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -13,7 +13,7 @@
@Service
@RequiredArgsConstructor
@Transactional
public class SignOutVolunteerService implements SignOutVolunteerUseCase {
public class SignOutService implements SignOutUseCase {

private final CookieUseCase cookieUseCase;
private final RefreshTokenManager refreshTokenManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.somemore.volunteer.usecase;
package com.somemore.auth.signout.usecase;

import jakarta.servlet.http.HttpServletResponse;

public interface SignOutVolunteerUseCase {
public interface SignOutUseCase {

void signOut(HttpServletResponse response, String volunteerId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.somemore.center.controller;

import com.somemore.auth.signout.usecase.SignOutUseCase;
import com.somemore.global.common.response.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/api/center")
@Tag(name = "center Sign API", description = "기관 로그아웃")
public class CenterSignController {

private final SignOutUseCase signOutUseCase;

@PostMapping("/sign-out")
public ApiResponse<String> signOut(
HttpServletResponse response,
@AuthenticationPrincipal String userId) {

signOutUseCase.signOut(response, userId);

return ApiResponse.ok("로그아웃되었습니다");
}
}
1 change: 1 addition & 0 deletions src/main/java/com/somemore/global/configure/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins(
"http://localhost:3000",
"http://localhost:5173",
"http://front-deploy.s3-website.ap-northeast-2.amazonaws.com"
)
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.somemore.global.common.response.ApiResponse;
import com.somemore.global.exception.BadRequestException;
import com.somemore.volunteer.usecase.SignOutVolunteerUseCase;
import com.somemore.auth.signout.usecase.SignOutUseCase;
import com.somemore.volunteer.usecase.GenerateOAuthUrlUseCase;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
Expand All @@ -25,7 +25,7 @@
public class VolunteerSignController {

private final GenerateOAuthUrlUseCase generateOAuthUrlUseCase;
private final SignOutVolunteerUseCase signOutVolunteerUseCase;
private final SignOutUseCase signOutUseCase;

@PostMapping("/sign-in/oauth/{oauthProvider}")
public RedirectView signIn(
Expand All @@ -42,11 +42,11 @@ public RedirectView signIn(
}

@PostMapping("/sign-out")
public ApiResponse<?> signOut(
public ApiResponse<String> signOut(
HttpServletResponse response,
@AuthenticationPrincipal String userId) {

signOutVolunteerUseCase.signOut(response, userId);
signOutUseCase.signOut(response, userId);

return ApiResponse.ok("로그아웃되었습니다");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.somemore.auth.jwt.generator.JwtGenerator;
import com.somemore.auth.jwt.refresh.domain.RefreshToken;
import com.somemore.auth.jwt.refresh.manager.RefreshTokenManager;
import com.somemore.auth.signout.service.SignOutService;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -25,7 +26,7 @@
class SignOutVolunteerServiceTest extends IntegrationTestSupport {

@Autowired
private SignOutVolunteerService signOutVolunteerService;
private SignOutService signOutVolunteerService;
@Autowired
private CookieUseCase cookieUseCase;
@Autowired
Expand Down