Skip to content

Commit

Permalink
Merge pull request #39 from sh1220/dev
Browse files Browse the repository at this point in the history
fix: User Exception
  • Loading branch information
sh1220 authored Aug 1, 2024
2 parents d3ec8f3 + 774e53c commit f57a7e9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/store/itpick/backend/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void addInterceptors(InterceptorRegistry registry) {
.order(1)
.addPathPatterns("/**")
.excludePathPatterns("/auth/login", "/auth/signup", "/auth/refresh","/auth/emails/**");
//인터셉터 적용 범위 수정

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class PostUserRequest {
@NotBlank(message = "password: {NotBlank}")
@Length(min = 8, max = 20,
message = "password: 최소 {min}자리 ~ 최대 {max}자리까지 가능합니다")
@Pattern(regexp = "(?=.*[a-z])(?=.*[0-9])(?=.*[!#$%^&*+=])(?=\\S+$).{8,20}",
@Pattern(regexp = "(?=.*[a-z])(?=.*[0-9])(?=.*[!#@$%^&*+=])(?=\\S+$).{8,20}",
message = "password: 소문자, 숫자, 특수문자가 적어도 하나씩은 있어야 합니다")
private String password;

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/store/itpick/backend/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.Random;

Expand Down Expand Up @@ -63,7 +64,7 @@ public LoginResponse login(LoginRequest authRequest) {
User user;
try {
user = userRepository.getUserByEmail(email).get();
} catch (IncorrectResultSizeDataAccessException e) {
} catch (NoSuchElementException e) {
throw new UserException(EMAIL_NOT_FOUND);
}
long userId = user.getUserId();
Expand Down Expand Up @@ -139,7 +140,7 @@ public void logout(long userId) {
User user;
try {
user = userRepository.getUserByUserId(userId).get();
} catch (IncorrectResultSizeDataAccessException e) {
} catch (NoSuchElementException e) {
throw new UserException(USER_NOT_FOUND);
}
user.setRefreshToken(null);
Expand Down

0 comments on commit f57a7e9

Please sign in to comment.