Skip to content

Commit

Permalink
#10 feat : LoginReq DTO 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
sycuuui committed May 29, 2024
1 parent 6b4696c commit eb29acb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package Journey.Together.domain.member.controller;

import Journey.Together.domain.member.dto.LoginReq;
import Journey.Together.domain.member.dto.LoginRes;
import Journey.Together.domain.member.enumerate.LoginType;
import Journey.Together.domain.member.service.AuthService;
Expand Down Expand Up @@ -30,8 +31,8 @@ public void login(HttpServletResponse response) throws IOException {
@Operation(summary = "로그인 API")
@PostMapping("/sign-in")
public ApiResponse<LoginRes> signIn(@RequestHeader("Authorization") String token,
@RequestBody String type) {
return ApiResponse.success(Success.LOGIN_SUCCESS,authService.signIn(token,type));
@RequestBody LoginReq loginReq) {
return ApiResponse.success(Success.LOGIN_SUCCESS,authService.signIn(token,loginReq));
}

@Operation(summary = "로그아웃 API", description = "로그아웃된 JWT 블랙리스트 등록")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package Journey.Together.domain.member.dto;

public record LoginReq(
String type
) {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package Journey.Together.domain.member.service;

import Journey.Together.domain.member.dto.LoginReq;
import Journey.Together.domain.member.dto.LoginRes;
import Journey.Together.domain.member.entity.Member;
import Journey.Together.domain.member.enumerate.LoginType;
Expand All @@ -11,8 +12,6 @@
import Journey.Together.global.security.kakao.dto.KakaoProfile;
import Journey.Together.global.security.jwt.TokenProvider;
import Journey.Together.global.security.jwt.dto.TokenDto;
import Journey.Together.global.security.kakao.dto.KakaoToken;
import Journey.Together.global.security.naver.dto.NaverProperties;
import Journey.Together.global.security.naver.dto.NaverUserResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpEntity;
Expand All @@ -35,11 +34,11 @@ public class AuthService {
private final RestTemplate restTemplate = new RestTemplate();

@Transactional
public LoginRes signIn(String token, String type) {
public LoginRes signIn(String token, LoginReq loginReq) {
Member member = null;
TokenDto tokenDto = null;

if(type.equals("KAKAO")) {
if((loginReq.type()).equals("KAKAO")) {
//Business Logic
// 카카오톡에 있는 사용자 정보 반환
KakaoProfile kakaoProfile = kakaoClient.getMemberInfo(token);
Expand All @@ -62,7 +61,7 @@ public LoginRes signIn(String token, String type) {
// Response
return LoginRes.of(member, tokenDto);

} else if (type.equals("NAVER")) {
} else if ((loginReq.type()).equals("NAVER")) {
NaverUserResponse.NaverUserDetail naverProfile = toRequestProfile(token.substring(7));
member = memberRepository.findMemberByEmailAndDeletedAtIsNull(naverProfile.getEmail()).orElse(null);

Expand Down Expand Up @@ -101,9 +100,6 @@ public void signOut(String token, Member member) {
tokenProvider.validateToken(accessToken);

// Business Logic - Refresh Token 삭제 및 Access Token 블랙리스트 등록
String key = member.getEmail();
// redisClient.deleteValue(key);
// redisClient.setValue(accessToken, "logout", tokenProvider.getExpiration(accessToken));
member.setRefreshToken(null);

// Response
Expand Down

0 comments on commit eb29acb

Please sign in to comment.