Skip to content

Commit

Permalink
Merge pull request #193 from Wingle-SMWU/fix/가입-수락된-회원만-로그인-허용-#188
Browse files Browse the repository at this point in the history
[fix] 승인된 유저만 로그인 허용 #188
  • Loading branch information
LeeJE20 committed Jul 3, 2023
2 parents 8308846 + bde1289 commit cdb7289
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public enum ErrorCode {
ALREADY_DENY(BAD_REQUEST, "이미 가입 거절한 유저입니다."),
ALREADY_WITHDRAWN(BAD_REQUEST, "이미 탈퇴한 유저입니다."),
NOT_ACCEPTED(BAD_REQUEST, "승인되지 않은 유저입니다."),
DENYED_USER(BAD_REQUEST, "가입 거절된 유저입니다"),
// 메일
EMAIL_BAD_REQUEST(BAD_REQUEST, "이메일 형식이 유효하지 않습니다."),
EMAIL_SEND_FAIL(BAD_REQUEST, "이메일을 전송할 수 없습니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ public LoginResponseDto login(LoginRequestDto loginRequestDto) {
Member member = memberRepository.findByEmail(email)
.orElseThrow(() -> new NotFoundException(ErrorCode.USER_NOT_FOUND));

// 승인된 유저만 허용
if (member.getPermission() == Permission.WAIT.getStatus()) {
throw new ForbiddenException(ErrorCode.NOT_ACCEPTED);
}
if (member.getPermission() == Permission.DENY.getStatus()) {
throw new ForbiddenException(ErrorCode.DENYED_USER);
}

UsernamePasswordAuthenticationToken authenticationToken = loginRequestDto.toAuthentication();
Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);
TokenDto tokenDto = getRedisTokenKey(authentication);
Expand Down

0 comments on commit cdb7289

Please sign in to comment.