diff --git a/src/main/java/idorm/idormServer/calendar/controller/TeamCalendarController.java b/src/main/java/idorm/idormServer/calendar/controller/TeamCalendarController.java index 9c387450..7061ade6 100644 --- a/src/main/java/idorm/idormServer/calendar/controller/TeamCalendarController.java +++ b/src/main/java/idorm/idormServer/calendar/controller/TeamCalendarController.java @@ -35,6 +35,7 @@ import java.util.List; import java.util.stream.Collectors; +import static idorm.idormServer.config.SecurityConfiguration.AUTHENTICATION_HEADER_NAME; import static idorm.idormServer.exception.ExceptionCode.TEAMCALENDAR_NOT_FOUND; @Api(tags = "공유 캘린더_일정 관리") @@ -70,7 +71,7 @@ public ResponseEntity> createTeamCalender( @RequestBody @Valid TeamCalendarSaveRequestDto request ) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); Team team = teamService.findByMember(member); @@ -122,7 +123,7 @@ public ResponseEntity> createSleepoverCalender( @RequestBody @Valid SleepoverCalendarDefaultRequestDto request ) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); Team team = teamService.findByMember(member); @@ -176,7 +177,7 @@ public ResponseEntity> updateSleepoverCalender( @RequestBody @Valid SleepoverCalendarUpdateRequestDto request ) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); Team team = teamService.findByMember(member); @@ -232,7 +233,7 @@ public ResponseEntity> updateTeamCalender( @RequestBody @Valid TeamCalendarUpdateRequestDto request ) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); Team team = teamService.findByMember(member); @@ -290,7 +291,7 @@ public ResponseEntity> deleteTeamCalender( Long teamCalendarId ) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); Team team = teamService.findByMember(member); @@ -334,7 +335,8 @@ public ResponseEntity> findTeamCalender( Long teamCalendarId ) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME + ))); Member member = memberService.findById(memberId); Team team = teamService.findByMember(member); @@ -383,7 +385,7 @@ public ResponseEntity> findTeamCalenders( @RequestBody @Valid CalendarFindManyRequestDto request ) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); Team team = teamService.findByMember(member); @@ -436,7 +438,7 @@ public ResponseEntity> findTeamSleepoverCalenders( @RequestBody @Valid SleepoverCalendarFindManyRequestDto request ) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); Member searchMember = memberService.findById(request.getMemberId()); diff --git a/src/main/java/idorm/idormServer/calendar/controller/TeamController.java b/src/main/java/idorm/idormServer/calendar/controller/TeamController.java index 1b5dc8f1..ccbc683e 100644 --- a/src/main/java/idorm/idormServer/calendar/controller/TeamController.java +++ b/src/main/java/idorm/idormServer/calendar/controller/TeamController.java @@ -29,6 +29,8 @@ import java.util.List; import java.util.stream.Collectors; +import static idorm.idormServer.config.SecurityConfiguration.AUTHENTICATION_HEADER_NAME; + @Api(tags = "공유 캘린더_팀 관리") @Validated @RestController @@ -66,7 +68,7 @@ public ResponseEntity> addTeamMember( Long registerMemberId ) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); Member registerMember = memberService.findById(registerMemberId); @@ -111,7 +113,7 @@ public ResponseEntity> deleteTeamMember( Long memberId ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member loginMember = memberService.findById(loginMemberId); Member deleteMember = memberService.findById(memberId); @@ -149,7 +151,7 @@ public ResponseEntity> deleteTeamMember( public ResponseEntity> findTeamMembers( HttpServletRequest servletRequest ) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); Team team = teamService.findByMemberOptional(member); @@ -202,7 +204,7 @@ public ResponseEntity> findTeamMembers( public ResponseEntity> isConfirmTeamExploded( HttpServletRequest servletRequest ) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); Team team = teamService.findByMemberOptional(member); diff --git a/src/main/java/idorm/idormServer/community/controller/CommunityController.java b/src/main/java/idorm/idormServer/community/controller/CommunityController.java index bf1fde89..9edb921e 100644 --- a/src/main/java/idorm/idormServer/community/controller/CommunityController.java +++ b/src/main/java/idorm/idormServer/community/controller/CommunityController.java @@ -48,6 +48,7 @@ import java.util.Optional; import java.util.stream.Collectors; +import static idorm.idormServer.config.SecurityConfiguration.AUTHENTICATION_HEADER_NAME; import static idorm.idormServer.exception.ExceptionCode.*; @Api(tags = "커뮤니티") @@ -87,7 +88,7 @@ public ResponseEntity> findPostsFilteredByCategory( @PathVariable(value = "dormitory-category") String dormCategoryRequest, @RequestParam(value = "page") int pageNum ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); memberService.findById(loginMemberId); DormCategory dormCategory = DormCategory.validateType(dormCategoryRequest); @@ -125,7 +126,7 @@ public ResponseEntity> findTopPostsFilteredByCategory HttpServletRequest servletRequest, @PathVariable("dormitory-category") String dormCategoryRequest ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); memberService.findById(loginMemberId); DormCategory dormCategory = DormCategory.validateType(dormCategoryRequest); @@ -166,7 +167,7 @@ public ResponseEntity> findOnePost( @Positive(message = "게시글 식별자는 양수만 가능합니다.") Long postId ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); Post foundPost = postService.findById(postId); @@ -253,7 +254,7 @@ public ResponseEntity> savePost( HttpServletRequest servletRequest, @ModelAttribute PostSaveRequestDto request ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); postService.validatePostRequest(request.getTitle(), request.getContent(), request.getIsAnonymous()); @@ -304,7 +305,7 @@ public ResponseEntity> updatePost( Long postId, @ModelAttribute PostUpdateRequestDto request ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); Post post = postService.findById(postId); @@ -348,7 +349,7 @@ public ResponseEntity> findPostsByMember( HttpServletRequest servletRequest ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); List posts = postService.findPostsByMember(member); @@ -380,7 +381,7 @@ public ResponseEntity> findPostsByMember( public ResponseEntity> findLikedPostsByMember( HttpServletRequest servletRequest ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); memberService.findById(loginMemberId); List likedPostIds = postLikedMemberService.findAllLikedPostIdByMemberId(loginMemberId); @@ -427,7 +428,7 @@ public ResponseEntity> savePostLikes( @Positive(message = "게시글 식별자는 양수만 가능합니다.") Long postId ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); Post post = postService.findById(postId); @@ -472,7 +473,7 @@ public ResponseEntity> deletePostLikes( @Positive(message = "게시글 식별자는 양수만 가능합니다.") Long postId ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); Post post = postService.findById(postId); @@ -510,7 +511,7 @@ public ResponseEntity> deletePost( @Positive(message = "게시글 식별자는 양수만 가능합니다.") Long postId ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); Post post = postService.findById(postId); @@ -559,7 +560,7 @@ public ResponseEntity> saveComment ( Long postId, @RequestBody @Valid CommentDefaultRequestDto request ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); Post post = postService.findById(postId); @@ -664,7 +665,7 @@ public ResponseEntity> deleteComment( @Positive(message = "댓글 식별자는 양수만 가능합니다.") Long commentId ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); Post post = postService.findById(postId); @@ -698,7 +699,7 @@ public ResponseEntity> deleteComment( public ResponseEntity> findCommentsByMember( HttpServletRequest servletRequest ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); List foundComments = commentService.findCommentsByMember(member); diff --git a/src/main/java/idorm/idormServer/config/SecurityConfiguration.java b/src/main/java/idorm/idormServer/config/SecurityConfiguration.java index 3da69ebe..bb404f2e 100644 --- a/src/main/java/idorm/idormServer/config/SecurityConfiguration.java +++ b/src/main/java/idorm/idormServer/config/SecurityConfiguration.java @@ -19,7 +19,7 @@ @EnableWebSecurity public class SecurityConfiguration extends WebSecurityConfigurerAdapter { - public static final String AUTHENTICATION_HEADER_NAME = "authorization"; + public static final String AUTHENTICATION_HEADER_NAME = "X-AUTH-TOKEN"; public static final String AUTHENTICATION_URL = "/api/auth"; public static final String API_ROOT_URL_V1 = "/api/v1"; diff --git a/src/main/java/idorm/idormServer/matching/controller/MatchingController.java b/src/main/java/idorm/idormServer/matching/controller/MatchingController.java index 3cb5b4a1..a3b6782b 100644 --- a/src/main/java/idorm/idormServer/matching/controller/MatchingController.java +++ b/src/main/java/idorm/idormServer/matching/controller/MatchingController.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.List; +import static idorm.idormServer.config.SecurityConfiguration.AUTHENTICATION_HEADER_NAME; import static idorm.idormServer.exception.ExceptionCode.*; @Api(tags = "매칭") @@ -60,7 +61,7 @@ public ResponseEntity> findLikedMatchingMembers( HttpServletRequest servletRequest ) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); List likedMembers = matchingService.findLikedMembers(member); @@ -98,7 +99,7 @@ public ResponseEntity> findDislikedMatchingMembers( HttpServletRequest servletRequest ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member loginMember = memberService.findById(loginMemberId); List dislikedMembers = matchingService.findDislikedMembers(loginMember); @@ -147,7 +148,7 @@ public ResponseEntity> addMatchingMember( Long selectedMemberId ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member loginMember = memberService.findById(loginMemberId); Member selectedMember = memberService.findById(selectedMemberId); @@ -208,7 +209,7 @@ public ResponseEntity> deleteMatchingMember( Long selectedMemberId ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(request.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(request.getHeader(AUTHENTICATION_HEADER_NAME))); Member loginMember = memberService.findById(loginMemberId); if (matchingType == true) { @@ -250,7 +251,7 @@ public ResponseEntity> findMatchingMembers( HttpServletRequest servletRequest ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member loginMember = memberService.findById(loginMemberId); matchingInfoService.findByMemberId(loginMemberId); @@ -295,7 +296,7 @@ public ResponseEntity> findFilteredMatchingMembers( @RequestBody @Valid MatchingFilteredMatchingInfoRequestDto request ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member loginMember = memberService.findById(loginMemberId); matchingInfoService.findByMemberId(loginMemberId); matchingInfoService.validateMatchingInfoIsPublic(loginMember); diff --git a/src/main/java/idorm/idormServer/matchingInfo/controller/MatchingInfoController.java b/src/main/java/idorm/idormServer/matchingInfo/controller/MatchingInfoController.java index a740ff38..5f63bc1a 100644 --- a/src/main/java/idorm/idormServer/matchingInfo/controller/MatchingInfoController.java +++ b/src/main/java/idorm/idormServer/matchingInfo/controller/MatchingInfoController.java @@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; +import static idorm.idormServer.config.SecurityConfiguration.AUTHENTICATION_HEADER_NAME; import static idorm.idormServer.exception.ExceptionCode.*; @Api(tags = "온보딩 매칭 정보") @@ -60,7 +61,7 @@ public ResponseEntity> save( HttpServletRequest servletRequest, @RequestBody @Valid MatchingInfoDefaultRequestDto request) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); matchingInfoService.validateMBTI(request.getMbti().toUpperCase()); @@ -102,7 +103,7 @@ public ResponseEntity> updateMatchingInfo( HttpServletRequest servletRequest, @RequestBody @Valid MatchingInfoDefaultRequestDto request) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); matchingInfoService.validateMBTI(request.getMbti().toUpperCase()); @@ -142,7 +143,7 @@ public ResponseEntity> updateisMatchingInfoPublic( HttpServletRequest servletRequest, MatchingInfoUpdateIsPublicRequestDto request) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); if(member.getMatchingInfo() == null) { @@ -176,7 +177,7 @@ public ResponseEntity> updateisMatchingInfoPublic( public ResponseEntity> findMatchingInfo( HttpServletRequest servletRequest) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); if(member.getMatchingInfo() == null) { // 등록된 매칭정보가 없다면 @@ -211,7 +212,7 @@ public ResponseEntity> findMatchingInfo( }) public ResponseEntity> deleteMatchingInfo(HttpServletRequest request2) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(request2.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(request2.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); if(member.getMatchingInfo() == null) { // 등록된 매칭정보가 없는 경우 diff --git a/src/main/java/idorm/idormServer/member/controller/MemberController.java b/src/main/java/idorm/idormServer/member/controller/MemberController.java index a9fbeb22..14d89e8c 100644 --- a/src/main/java/idorm/idormServer/member/controller/MemberController.java +++ b/src/main/java/idorm/idormServer/member/controller/MemberController.java @@ -32,6 +32,7 @@ import static idorm.idormServer.config.SecurityConfiguration.API_ROOT_URL_V1; import static idorm.idormServer.config.SecurityConfiguration.AUTHENTICATION_HEADER_NAME; import static idorm.idormServer.exception.ExceptionCode.*; +import static org.springframework.http.HttpHeaders.AUTHORIZATION; @Api(tags = "회원") @Validated @@ -63,7 +64,7 @@ public class MemberController { public ResponseEntity> findOneMember( HttpServletRequest servletRequest ) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); MemberDefaultResponseDto response = new MemberDefaultResponseDto(member); @@ -145,7 +146,7 @@ public ResponseEntity> saveMemberPhoto( HttpServletRequest servletRequest, @RequestPart(value = "file", required = false) MultipartFile file) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); photoService.validateFileExistence(file); @@ -178,7 +179,7 @@ public ResponseEntity> saveMemberPhoto( public ResponseEntity> deleteMemberPhoto( HttpServletRequest servletRequest) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); memberPhotoService.validateMemberPhotoIsExistence(member); @@ -251,7 +252,7 @@ public ResponseEntity> updateMemberNickname( HttpServletRequest servletRequest, @RequestBody @Valid MemberUpdateNicknameRequestDto request) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); memberService.validateUpdateNicknameIsChanged(member, request.getNickname()); @@ -283,7 +284,7 @@ public ResponseEntity> updateMemberNickname( public ResponseEntity> deleteMember( HttpServletRequest servletRequest ) { - long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + long memberId = Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(memberId); memberServiceFacade.deleteMember(member); @@ -328,7 +329,7 @@ public ResponseEntity> login( MemberDefaultResponseDto response = new MemberDefaultResponseDto(member); return ResponseEntity.status(200) - .header(AUTHENTICATION_HEADER_NAME, token) + .header(AUTHORIZATION, token) .body(DefaultResponseDto.builder() .responseCode("MEMBER_LOGIN") .responseMessage("회원 로그인 완료") @@ -358,7 +359,7 @@ public ResponseEntity> updateFcmToken( HttpServletRequest request, @RequestHeader("fcm-token") String fcmToken) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(request.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(request.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); memberService.updateFcmToken(member, fcmToken); @@ -388,7 +389,7 @@ public ResponseEntity> updateFcmToken( public ResponseEntity> logout( HttpServletRequest request) { - long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(request.getHeader("X-AUTH-TOKEN"))); + long loginMemberId = Long.parseLong(jwtTokenProvider.getUsername(request.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); memberService.deleteFcmToken(member); diff --git a/src/main/java/idorm/idormServer/report/controller/ReportController.java b/src/main/java/idorm/idormServer/report/controller/ReportController.java index bd694312..6442739d 100644 --- a/src/main/java/idorm/idormServer/report/controller/ReportController.java +++ b/src/main/java/idorm/idormServer/report/controller/ReportController.java @@ -27,6 +27,8 @@ import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; +import static idorm.idormServer.config.SecurityConfiguration.AUTHENTICATION_HEADER_NAME; + @Api(tags = "신고") @Validated @RestController @@ -59,7 +61,7 @@ public ResponseEntity> reportMemberOrPostOrComment( @RequestBody @Valid ReportDefaultRequestDto request) { long loginMemberId = - Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader("X-AUTH-TOKEN"))); + Long.parseLong(jwtTokenProvider.getUsername(servletRequest.getHeader(AUTHENTICATION_HEADER_NAME))); Member member = memberService.findById(loginMemberId); ReportType reportType = ReportType.validateType(request.getReportType());