Skip to content

Commit

Permalink
refactor : 로그인, 회원가입 fcmToken 등록 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
13wjdgk committed Oct 31, 2023
1 parent 9458c12 commit 1aeb69c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,27 @@ public class LoginController {
private static String headerKeyAuthorization = "Authorization";

/**
* @param params 카카오 accessToken
* @param request request에서 fcmToken header가 필요
* @param params 카카오 accessToken
* @return ResponseEntity 로그인을 성공하면, JWT TOKEN과 사용자 정보(nickname, auth id)를 전달한다.
* @since 1.0.0
*/
@PostMapping("/kakao")
public ResponseEntity<SuccessSingleResponse<LoginResponse>> loginKakao(@Valid @RequestBody KakaoLoginRequest params, HttpServletRequest request) {
LoginResponse loginResponse = oauthLoginService.login(params, request.getHeader(headerKeyFcmToken));
public ResponseEntity<SuccessSingleResponse<LoginResponse>> loginKakao(@Valid @RequestBody KakaoLoginRequest params) {
LoginResponse loginResponse = oauthLoginService.login(params);
String accessToken = oauthLoginService.getAuthToken(loginResponse.nickname());
return ResponseEntity.ok()
.header(headerKeyAccessToken.toString(), accessToken)
.body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), loginResponse));
}

/**
* @param params 네이버 accessToken
* @param request request에서 fcmToken header가 필요
* @param params 네이버 accessToken
* @return ResponseEntity 로그인을 성공하면, JWT TOKEN과 사용자 정보(nickname, auth id)를 전달한다.
* @since 1.0.0
*/
@PostMapping("/naver")
public ResponseEntity<SuccessSingleResponse<LoginResponse>> loginNaver(@Valid @RequestBody NaverLoginRequest params, HttpServletRequest request) {
LoginResponse loginResponse = oauthLoginService.login(params, request.getHeader(headerKeyFcmToken));
public ResponseEntity<SuccessSingleResponse<LoginResponse>> loginNaver(@Valid @RequestBody NaverLoginRequest params) {
LoginResponse loginResponse = oauthLoginService.login(params);
String accessToken = oauthLoginService.getAuthToken(loginResponse.nickname());
return ResponseEntity.ok()
.header(headerKeyAccessToken, accessToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,12 @@ public DefaultOauthLoginService(AuthTokenGenerator authTokenGenerator, UserSearc
}

/**
* @param params 카카오,네이버 accessToken
* @param fcmToken notifiaction 디바이스 토큰
* @param params 카카오,네이버 accessToken
* @return Content 로그인을 성공하면, JWT TOKEN과 사용자 정보(nickname, authID)를 전달한다.
* @since 1.0.0
*/
@Override
public LoginResponse login(OauthLoginRequest params, String fcmToken) {
public LoginResponse login(OauthLoginRequest params) {
OAuthInfoResponse oAuthInfoResponse = request(params);
User user = userSearchService.findUserByOauthId(oAuthInfoResponse.getOauthId());
HealthConnect healthConnect = userSearchService.findInterlockHealthConnect(user.getOauthId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @since 1.0.0
*/
public interface OauthLoginService {
LoginResponse login(OauthLoginRequest params, String fcmToken);
LoginResponse login(OauthLoginRequest params);

String getAuthToken(String nickname);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.coniverse.dangjang.domain.user.service.UserSignupService;
import com.coniverse.dangjang.global.dto.SuccessSingleResponse;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

Expand All @@ -27,18 +26,16 @@
public class SignupController {
private final UserSignupService userSignupService;
private final OauthLoginService oauthLoginService;
private static String headerKeyFcmToken = "FcmToken";
private static String headerKeyAccessToken = "AccessToken";

/**
* @param params 회원가입에 필요한 정보를 담아온다.
* @param request request에서 fcmToken header 이용
* @param params 회원가입에 필요한 정보를 담아온다.
* @return 회원가입 후 로그인을 시도 , ResponseEntity 로그인을 성공하면, JWT TOKEN과 사용자 정보(nickname, authID)를 전달한다.
* @since 1.0
*/
@PostMapping
public ResponseEntity<SuccessSingleResponse<LoginResponse>> signUp(@Valid @RequestBody SignUpRequest params, HttpServletRequest request) {
LoginResponse loginResponse = userSignupService.signUp(params, request.getHeader(headerKeyFcmToken));
public ResponseEntity<SuccessSingleResponse<LoginResponse>> signUp(@Valid @RequestBody SignUpRequest params) {
LoginResponse loginResponse = userSignupService.signUp(params);
String accessToken = oauthLoginService.getAuthToken(loginResponse.nickname());
return ResponseEntity.ok()
.header(headerKeyAccessToken, accessToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ public class UserSignupService {
* 회원가입
*
* @param signUpRequest 회원가입 정보
* @param fcmToken notification 디바이스 토큰
* @return LoginResponse 로그인 응답
* @since 1.0.0
*/
public LoginResponse signUp(SignUpRequest signUpRequest, String fcmToken) {
public LoginResponse signUp(SignUpRequest signUpRequest) {
OAuthInfoResponse oAuthInfoResponse = getOauthInfo(OauthProvider.of(signUpRequest.provider()), signUpRequest.accessToken());
ActivityAmount activityAmount = ActivityAmount.of(signUpRequest.activityAmount());
Gender gender = Gender.of(signUpRequest.gender());
Expand Down

0 comments on commit 1aeb69c

Please sign in to comment.