Skip to content

Commit

Permalink
feat : 로그인 실패 예외처리
Browse files Browse the repository at this point in the history
  • Loading branch information
KangJiSseok committed May 15, 2024
1 parent dcaa460 commit 7bb8612
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ExceptionAdvice {
public ResponseEntity<ApiResponse<?>> handleDuplicatedUserException(BusinessException e) {
final ErrorCode errorCode = e.getErrorCode();

return ResponseEntity.status(HttpStatus.CONFLICT).body(ApiResponse.createError(errorCode.getMessage()));
return ResponseEntity.status(errorCode.getStatus()).body(ApiResponse.createError(errorCode.getMessage()));
}

@ExceptionHandler(MethodArgumentNotValidException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public enum ErrorCode {

// Member
EMAIL_ALREADY_TAKEN(400, "이미 존재하는 이메일입니다."),

LOGIN_FAIL_TAKEN(400,"로그인 실패"),

//Friend
FRIEND_ALREADT_TAKEN(400,"이미 친구 요청을 보낸 상대입니다.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@


import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class TokenMessage {
String AccessToken;
String RefreshToken;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package springwebsocket.webchat.member.exception;

import springwebsocket.webchat.global.error.BusinessException;
import springwebsocket.webchat.global.response.ErrorCode;

import static springwebsocket.webchat.global.response.ErrorCode.LOGIN_FAIL_TAKEN;

public class LoginFailException extends BusinessException {

public LoginFailException() {
super(LOGIN_FAIL_TAKEN);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import springwebsocket.webchat.member.dto.response.UserResponse;
import springwebsocket.webchat.member.entity.Member;
import springwebsocket.webchat.member.exception.EmailDuplicatedException;
import springwebsocket.webchat.member.exception.LoginFailException;
import springwebsocket.webchat.member.repository.MemberRepository;
import springwebsocket.webchat.member.repository.RefreshMemberRepository;

Expand Down Expand Up @@ -84,7 +85,7 @@ public TokenMessage login(String loginEmail, String password) {
if (!user.isEmpty()) {
return handleExistingMemberLogin(user.get());
} else {
throw null;
throw new LoginFailException();
}
}

Expand Down
6 changes: 3 additions & 3 deletions BackEnd/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ spring:
url: ${MYSQL_DATABASE_URL}
username: ${MYSQL_DATABASE_USERNAME}
password: ${MYSQL_DATABASE_PASSWORD}
# url: "jdbc:mysql://localhost:3306/JPA?characterEncoding=UTF-8&serverTimezone=UTC"
# username: "springDB"
# password:
# url: "jdbc:mysql://localhost:3306/JPA?characterEncoding=UTF-8&serverTimezone=UTC"
# username: "springDB"
# password:
jpa:
show-sql: true
hibernate:
Expand Down

0 comments on commit 7bb8612

Please sign in to comment.