Skip to content

Commit

Permalink
Merge pull request #22 from Central-MakeUs/1-social-login-구현하기
Browse files Browse the repository at this point in the history
�Fix(#1): 로그인 API response 수정
  • Loading branch information
tmddus2 authored Aug 3, 2024
2 parents 6085e50 + fd2fad8 commit c989a55
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.example.purithm.global.auth.controller;

import com.example.purithm.global.auth.dto.response.KakaoUserInfoDto;
import com.example.purithm.global.auth.dto.response.LoginDto;
import com.example.purithm.global.auth.dto.response.SocialUserInfoDto;
import com.example.purithm.global.auth.jwt.JWTUtil;
import com.example.purithm.global.config.WebClientConfig;
Expand Down Expand Up @@ -32,7 +33,7 @@ public class AuthController implements AuthControllerDocs {
private final JWTUtil jwtUtil;

@GetMapping("/kakao")
public Mono<SuccessResponse<String>> kakaoLogin(String token) {
public Mono<SuccessResponse<LoginDto>> kakaoLogin(String token) {
return webClientConfig.webClient()
.post()
.uri("https://kapi.kakao.com/v2/user/me")
Expand All @@ -51,8 +52,9 @@ public Mono<SuccessResponse<String>> kakaoLogin(String token) {
Long id = userService.signUp(userInfoDto);
String jwtToken = jwtUtil.createJwt(id, 60 * 60 * 60 * 1000L);

SuccessResponse<String> body = SuccessResponse.of(jwtToken);
return Mono.just(body);
LoginDto loginDto = LoginDto.builder()
.accessToken(jwtToken).build();
return Mono.just(SuccessResponse.of(loginDto));
})
.onErrorResume(err -> {
log.error(err.getMessage());
Expand All @@ -61,7 +63,7 @@ public Mono<SuccessResponse<String>> kakaoLogin(String token) {
}

@GetMapping("/apple")
public SuccessResponse<String> appleLogin(String token, String username)
public SuccessResponse<LoginDto> appleLogin(String token, String username)
throws IOException, ParseException, JOSEException {

try {
Expand All @@ -76,7 +78,9 @@ public SuccessResponse<String> appleLogin(String token, String username)
Long id = userService.signUp(userInfoDto);
String jwtToken = jwtUtil.createJwt(id, 60 * 60 * 60 * 1000L);

return SuccessResponse.of(jwtToken);
LoginDto loginDto = LoginDto.builder()
.accessToken(jwtToken).build();
return SuccessResponse.of(loginDto);
} catch (Exception e) {
log.error(e.getMessage());
throw CustomException.of(Error.INVALID_TOKEN_ERROR);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.purithm.global.auth.controller;

import com.example.purithm.global.auth.dto.response.LoginDto;
import com.example.purithm.global.response.SuccessResponse;
import com.nimbusds.jose.JOSEException;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -20,15 +21,15 @@ public interface AuthControllerDocs {
@Parameter(name = "Authorization", description = "kakao access token을 보냅니다. Bearer token 형식입니다.", required = true, in = ParameterIn.HEADER)
}
)
public Mono<SuccessResponse<String>> kakaoLogin(@RequestHeader("Authorization") String token);
public Mono<SuccessResponse<LoginDto>> kakaoLogin(@RequestHeader("Authorization") String token);

@Operation(
summary = "Apple Login",
parameters = {
@Parameter(name = "Authorization", description = "Apple access token을 보냅니다. Bearer token 형식입니다.", required = true, in = ParameterIn.HEADER, schema = @Schema(type = "string"))
}
)
public SuccessResponse<String> appleLogin(
public SuccessResponse<LoginDto> appleLogin(
@RequestHeader("Authorization") String token, @RequestParam(value = "username", required = false) String username)
throws IOException, ParseException, JOSEException;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.example.purithm.global.auth.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;

@Builder
@Getter
public class LoginDto {
int code;
String message;
String token;
public record LoginDto(
@Schema(description = "token 값")
String accessToken
) {
}

This file was deleted.

0 comments on commit c989a55

Please sign in to comment.