Skip to content

Commit

Permalink
Merge pull request #68 from CSID-DGU/back
Browse files Browse the repository at this point in the history
11/15 배포 - 카카오로그인 패치
  • Loading branch information
proysm authored Nov 15, 2024
2 parents 06c99af + c5cfad4 commit 21fadc7
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class KakaoLoginController {

@Operation(summary = "프론트로부터 카카오 인가코드 전달받기")
@Parameter(name = "code", description = "카카오에서 받은 인카코드, RequestParam")
@PostMapping("/login")
@PostMapping("/login/code")
public ApiResponse<?> kakaoLoginCode(@RequestParam("code") String code){

String token = kakaoLoginService.getKakaoToken(code);
Expand All @@ -42,6 +42,25 @@ public ApiResponse<?> kakaoLoginCode(@RequestParam("code") String code){
return ApiResponse.onSuccess(Status.LOGIN_SUCCESS, dto);
}

@Operation(summary = "프론트로부터 카카오 토큰 전달받기")
@Parameter(name = "token", description = "카카오에서 받은 토큰, RequestParam")
@PostMapping("/login/token")
public ApiResponse<?> kakaoLoginToken(@RequestParam("token") String token){

KakaoLoginDto.KakaoUserInfoDto kakaoUserInfoDto = kakaoLoginService.getKakaoUserInfo(token);

if(userAccountService.findByEmail(kakaoUserInfoDto.getEmail()).isEmpty()) userAccountService.saveKakaoUser(kakaoUserInfoDto.getEmail());
User user = userAccountService.findByEmail(kakaoUserInfoDto.getEmail()).get();

String jwtToken = jwtUtil.createJwt(user.getId(), user.getNickname(), 3600000L);
KakaoLoginDto.LoginResponseDto dto = new KakaoLoginDto.LoginResponseDto().builder()
.userId(user.getId())
.token(jwtToken)
.build();

return ApiResponse.onSuccess(Status.LOGIN_SUCCESS, dto);
}

@Operation(summary = "인가코드 발급 API")
@GetMapping("/callback")
public ApiResponse<?> testInga(@RequestParam("code") String code){
Expand Down

0 comments on commit 21fadc7

Please sign in to comment.