-
Notifications
You must be signed in to change notification settings - Fork 50
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
[jangbagoony팀 이노 & MJ] OAuth 구현, 로그인, 로그아웃 API 구현 #67
base: jangbagoony
Are you sure you want to change the base?
Changes from all commits
6aa804d
9d03e7e
df1e5f6
d864fc7
6f68d80
a9359ee
723183b
9927adf
6f1741c
5613928
6bd1259
c8941b7
0407f81
33dd601
4b8befa
b2af3cc
776c70f
0524fc4
d3f321c
a30999e
8eea57a
8e9697e
ea963cc
9931723
59debf3
1e39cc5
e9615a1
101c4a7
df1d29f
914a8eb
3ddcfc4
608993f
423ebf8
131f40a
e87c930
4071738
73b2daf
2266a10
ad6d179
a3adbec
811b919
5ff87bc
f84f5f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
package com.mj_eno.sidedish.config; | ||
|
||
import org.springframework.web.cors.CorsConfiguration; | ||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | ||
import org.springframework.web.filter.CorsFilter; | ||
|
||
public class MyCorsFilter extends CorsFilter { | ||
|
||
public MyCorsFilter() { | ||
super(configurationSource()); | ||
} | ||
|
||
private static UrlBasedCorsConfigurationSource configurationSource() { | ||
CorsConfiguration config = new CorsConfiguration(); | ||
config.setAllowCredentials(true); | ||
config.addAllowedOrigin("http://15.164.68.136/"); | ||
config.addAllowedOrigin("http://localhost:3000/"); | ||
config.addAllowedHeader("*"); | ||
config.addAllowedMethod("*"); | ||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
source.registerCorsConfiguration("/**", config); | ||
return source; | ||
} | ||
} | ||
//package com.mj_eno.sidedish.config; | ||
// | ||
//import org.springframework.web.cors.CorsConfiguration; | ||
//import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | ||
//import org.springframework.web.filter.CorsFilter; | ||
// | ||
//public class MyCorsFilter extends CorsFilter { | ||
// | ||
// public MyCorsFilter() { | ||
// super(configurationSource()); | ||
// } | ||
// | ||
// private static UrlBasedCorsConfigurationSource configurationSource() { | ||
// CorsConfiguration config = new CorsConfiguration(); | ||
// config.setAllowCredentials(true); | ||
// config.addAllowedOrigin("http://15.164.68.136/"); | ||
// config.addAllowedOrigin("http://localhost:3000/"); | ||
// config.addAllowedHeader("*"); | ||
// config.addAllowedMethod("*"); | ||
// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
// source.registerCorsConfiguration("/**", config); | ||
// return source; | ||
// } | ||
//} |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.mj_eno.sidedish.domain.user; | ||
|
||
import com.mj_eno.sidedish.web.dto.EmailDTO; | ||
import com.mj_eno.sidedish.web.dto.TokenDTO; | ||
import com.mj_eno.sidedish.web.dto.UserInfoDTO; | ||
import org.springframework.data.annotation.Id; | ||
|
||
public class User { | ||
|
||
@Id | ||
private Long id; | ||
private String name; | ||
private String email; | ||
private String userId; | ||
private String token; | ||
|
||
public User() {} | ||
|
||
public User(UserInfoDTO userInfoDTO, EmailDTO emailDTO, TokenDTO tokenDTO) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DTO에서 정보를 가져오는 구현이 꼭 필요하다면, 별도의 스태틱 메소드나 빌더를 활용해 주시고요, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오홍!! 그렇군요. 타입을 그대로 받는 생성자를 만들고 스태틱 메소드를 활용하도록 하겠습니다. 지적해 주신 부분 생각해보니까 타입을 그대로 받는 생성자가 좀 더 범용성?이 있겠네요!! 감사합니다. |
||
this.name = userInfoDTO.getName(); | ||
this.email = emailDTO.getEmail(); | ||
this.userId = userInfoDTO.getLogin(); | ||
this.token = tokenDTO.getAccess_token(); | ||
} | ||
|
||
public void update(UserInfoDTO userInfoDTO, EmailDTO emailDTO, TokenDTO tokenDTO) { | ||
this.name = userInfoDTO.getName(); | ||
this.email = emailDTO.getEmail(); | ||
this.userId = userInfoDTO.getLogin(); | ||
this.token = tokenDTO.getAccess_token(); | ||
} | ||
|
||
public void removeToken() { | ||
this.token = null; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public String getUserId() { | ||
return userId; | ||
} | ||
|
||
public String getToken() { | ||
return token; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "User{" + | ||
"id=" + id + | ||
", name='" + name + '\'' + | ||
", email='" + email + '\'' + | ||
", userId='" + userId + '\'' + | ||
", token='" + token + '\'' + | ||
'}'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.mj_eno.sidedish.domain.user; | ||
|
||
import org.springframework.data.repository.CrudRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface UserRepository extends CrudRepository<User, Long> { | ||
|
||
Optional<User> findByEmail(String email); | ||
|
||
Optional<User> findByToken(String token); | ||
} |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.findFirst()
를 쓰면 예외 처리까지 잘 할 수 있겠네요.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분 리스트에서는 어떻게 예외처리를 하지? 싶었다가 넘긴 부분이였는데
findFirst()
라는 메소드가 있군요. 참고하겠습니다. 감사해요!!ㅎㅎ