Skip to content

Commit

Permalink
Merge pull request #69 from locavell/feat/#57
Browse files Browse the repository at this point in the history
[#57] 내지역 설정 변경
  • Loading branch information
m020202 authored Aug 19, 2024
2 parents 2cc22cf + 3b503b3 commit f637043
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
//TODO : 등급 관련 api 일단 모두 허용, 추후 삭제
.requestMatchers("/api/users/{user_id}/grade").permitAll()
.requestMatchers("/api/users/{user_id}/grade").permitAll()
.requestMatchers("/api/users/**").permitAll()
//TODO : 헬스체크용 api 허용
.requestMatchers("/health").permitAll()
.anyRequest().authenticated()) // 위의 경로 이외에는 모두 인증된 사용자만 접근 가능
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/example/locavel/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class User extends BaseEntity {
@Enumerated(EnumType.STRING)
private Grade travelerGrade = Grade.IRON;

@OneToOne(cascade = CascadeType.ALL)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "region_id")
private Region my_area;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ public Grade calculateLocalGrade ( int score){
@Override
@Transactional
public User setMyArea(HttpServletRequest httpServletRequest, String distinct) {
String email = httpServletRequest.getUserPrincipal().getName();
User user = userRepository.findByEmail(email).orElseThrow(() -> new UserHandler(ErrorStatus.USER_NOT_FOUND));
User user = getUser(httpServletRequest);
Region region = regionRepository.findByName(distinct);
user.setMy_area(region);
userRepository.save(user);
Expand Down

0 comments on commit f637043

Please sign in to comment.