-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 인가코드를 프론트에서 건네받아 토큰 요청하는 흐름으로 변경 - userRepository 조회로직 직접 조회로 변경 (후에 삭제한 회원 로직 추가해야) - loginDto 값 조정 및 패키지 이동
- Loading branch information
Showing
9 changed files
with
349 additions
and
46 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
31 changes: 31 additions & 0 deletions
31
src/main/java/com/ogjg/daitgym/user/controller/LoginController.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,31 @@ | ||
package com.ogjg.daitgym.user.controller; | ||
|
||
import com.ogjg.daitgym.common.exception.ErrorCode; | ||
import com.ogjg.daitgym.common.response.ApiResponse; | ||
import com.ogjg.daitgym.user.dto.LoginResponseDto; | ||
import com.ogjg.daitgym.user.service.AuthService; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class LoginController { | ||
|
||
private final AuthService authService; | ||
|
||
@GetMapping("/login/oauth2/callback/kakao") | ||
public ApiResponse<LoginResponseDto> kakaoLogin( | ||
@RequestParam("code") String code, | ||
HttpServletResponse httpServletResponse | ||
) { | ||
String kakaoAccessToken = authService.getKakaoAccessToken(code).getAccess_token(); | ||
|
||
return new ApiResponse<>( | ||
ErrorCode.SUCCESS, | ||
authService.kakaoLogin(kakaoAccessToken, httpServletResponse) | ||
); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/ogjg/daitgym/user/dto/KakaoAccountDto.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,23 @@ | ||
package com.ogjg.daitgym.user.dto; | ||
|
||
import lombok.Data; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class KakaoAccountDto { | ||
|
||
private Long id; | ||
private KakaoAccount kakao_account; | ||
@Data | ||
public static class KakaoAccount { | ||
|
||
private String email; | ||
private Profile profile; | ||
|
||
@Data | ||
public static class Profile { | ||
|
||
private String nickname; | ||
} | ||
} | ||
} |
25 changes: 15 additions & 10 deletions
25
.../security/oauth/dto/LoginResponseDto.java → ...jg/daitgym/user/dto/LoginResponseDto.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
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
Oops, something went wrong.