Skip to content

Commit

Permalink
[Fix] 로그인 오류
Browse files Browse the repository at this point in the history
  • Loading branch information
nahyeon99 committed Aug 17, 2023
1 parent a5d7ebb commit 747e761
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "공유 캘린더_일정 관리")
Expand Down Expand Up @@ -70,7 +71,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down Expand Up @@ -122,7 +123,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down Expand Up @@ -176,7 +177,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down Expand Up @@ -232,7 +233,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down Expand Up @@ -290,7 +291,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down Expand Up @@ -334,7 +335,8 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);
Expand Down Expand Up @@ -383,7 +385,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down Expand Up @@ -436,7 +438,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,7 +68,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down Expand Up @@ -111,7 +113,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down Expand Up @@ -149,7 +151,7 @@ public ResponseEntity<DefaultResponseDto<Object>> deleteTeamMember(
public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down Expand Up @@ -202,7 +204,7 @@ public ResponseEntity<DefaultResponseDto<Object>> findTeamMembers(
public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "커뮤니티")
Expand Down Expand Up @@ -87,7 +88,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);
Expand Down Expand Up @@ -125,7 +126,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);
Expand Down Expand Up @@ -166,7 +167,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down Expand Up @@ -253,7 +254,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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());
Expand Down Expand Up @@ -304,7 +305,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down Expand Up @@ -348,7 +349,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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<Post> posts = postService.findPostsByMember(member);

Expand Down Expand Up @@ -380,7 +381,7 @@ public ResponseEntity<DefaultResponseDto<Object>> findPostsByMember(
public ResponseEntity<DefaultResponseDto<Object>> 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<Long> likedPostIds = postLikedMemberService.findAllLikedPostIdByMemberId(loginMemberId);
Expand Down Expand Up @@ -427,7 +428,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down Expand Up @@ -472,7 +473,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down Expand Up @@ -510,7 +511,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);
Expand Down Expand Up @@ -559,7 +560,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);
Expand Down Expand Up @@ -664,7 +665,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);
Expand Down Expand Up @@ -698,7 +699,7 @@ public ResponseEntity<DefaultResponseDto<Object>> deleteComment(
public ResponseEntity<DefaultResponseDto<Object>> 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<Comment> foundComments = commentService.findCommentsByMember(member);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "매칭")
Expand Down Expand Up @@ -60,7 +61,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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<Member> likedMembers = matchingService.findLikedMembers(member);
Expand Down Expand Up @@ -98,7 +99,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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<Member> dislikedMembers = matchingService.findDislikedMembers(loginMember);
Expand Down Expand Up @@ -147,7 +148,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);

Expand Down Expand Up @@ -208,7 +209,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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) {
Expand Down Expand Up @@ -250,7 +251,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);
Expand Down Expand Up @@ -295,7 +296,7 @@ public ResponseEntity<DefaultResponseDto<Object>> 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);
Expand Down
Loading

0 comments on commit 747e761

Please sign in to comment.