Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(#1): 로그인 API response 수정 #22

Merged
merged 1 commit into from
Aug 3, 2024
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
@@ -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.