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

Feat-issue 58 #59

Merged
merged 1 commit into from
Feb 1, 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 @@ -73,11 +73,6 @@ public SignupResponseDto signup(SignupRequestDto signupRequestDto) {
}

public ResponseEntity<TokenResponseDto> login(LoginRequestDto loginRequestDto) {
Member member = memberRepository.findByEmail(loginRequestDto.getEmail())
.orElseThrow(() -> new NotFoundMemberException(ErrorCode.NOT_FOUND_MEMBER_ERROR));

validMemberState(member); // member State 검증

Authentication authentication = getAuthentication(loginRequestDto);

String accessToken = tokenProvider.createAccessToken(authentication);
Expand Down Expand Up @@ -159,15 +154,6 @@ private void passwordConfirm(String password, String passwordConfirm) {
}
}

/**
* Member state 검증
* @param member
*/
private static void validMemberState(Member member) {
if (member.getState() == State.DELETE){
throw new MemberStateException(ErrorCode.NOT_VALID_MEMBER_STATE_ERROR);
}
}

/**
* loginMember 검증
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.tadak.userservice.domain.member.entity.Member;
import com.tadak.userservice.domain.member.entity.State;
import com.tadak.userservice.domain.member.exception.MemberStateException;
import com.tadak.userservice.domain.member.repository.MemberRepository;
import com.tadak.userservice.global.error.ErrorCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.GrantedAuthority;
Expand Down Expand Up @@ -34,7 +36,7 @@ public UserDetails loadUserByUsername(String email) throws UsernameNotFoundExcep

private UserDetails createMember(String username, Member member) {
if (!member.getState().equals(State.ACTIVE)) {
throw new RuntimeException(username + " -> 활성화되어 있지 않습니다.");
throw new MemberStateException(ErrorCode.NOT_VALID_MEMBER_STATE_ERROR);
}

// List<GrantedAuthority> grantedAuthorities = member.getMemberAuthorities().stream()
Expand Down