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: 유저 생성이 안되는 오류 해결(#138) #139

Merged
merged 1 commit into from
Sep 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
Expand Up @@ -2,6 +2,7 @@

import java.io.IOException;

import com.soongsil.CoffeeChat.dto.Oauth.UserDTO;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
Expand All @@ -10,7 +11,6 @@
import org.springframework.web.filter.OncePerRequestFilter;

import com.soongsil.CoffeeChat.dto.Oauth.CustomOAuth2User;
import com.soongsil.CoffeeChat.dto.UserDTO;

import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.oauth2.core.user.OAuth2User;

import com.soongsil.CoffeeChat.dto.UserDTO;

public class CustomOAuth2User implements OAuth2User {
private final UserDTO userDTO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.soongsil.CoffeeChat.dto;
package com.soongsil.CoffeeChat.dto.Oauth;

import lombok.Getter;
import lombok.Setter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package com.soongsil.CoffeeChat.service;

import com.soongsil.CoffeeChat.controller.exception.CustomException;
import com.soongsil.CoffeeChat.dto.Oauth.*;
import org.springframework.security.oauth2.client.userinfo.DefaultOAuth2UserService;
import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest;
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Service;

import com.soongsil.CoffeeChat.dto.Oauth.CustomOAuth2User;
import com.soongsil.CoffeeChat.dto.Oauth.GoogleResponse;
import com.soongsil.CoffeeChat.dto.Oauth.KakaoResponse;
import com.soongsil.CoffeeChat.dto.Oauth.NaverResponse;
import com.soongsil.CoffeeChat.dto.Oauth.OAuth2Response;
import com.soongsil.CoffeeChat.dto.UserDTO;
import com.soongsil.CoffeeChat.entity.User;
import com.soongsil.CoffeeChat.repository.User.UserRepository;

Expand All @@ -30,10 +25,7 @@ public CustomOAuth2UserService(UserRepository userRepository) {

private User findUserByUsername(String username){
return userRepository.findByUsername(username)
.orElseThrow(() -> new CustomException(
USER_NOT_FOUND.getHttpStatusCode(),
USER_NOT_FOUND.getErrorMessage())
);
.orElse(null);
}

//리소스 서버에서 제공되는 유저정보 가져오기
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public String sendAuthenticationEmail(String receiver) throws InterruptedExcepti
} catch (Exception e) {
// 예외가 발생했을 때 로그를 남기고, 기본 코드 반환 등을 처리
System.out.println("SQS 메시지 전송 실패: " + e.getMessage());
throw new RuntimeException("메일전송실패");
}

return code;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spring:
password: ${DB_PW}
jpa:
hibernate:
ddl-auto: none
ddl-auto: update
naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
database: mysql
Expand Down
Loading