Skip to content

Commit

Permalink
Refactor: merge & conflict resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
sh1220 committed Aug 1, 2024
1 parent b17e3a4 commit 9512a85
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 42 deletions.
5 changes: 0 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ dependencies {

implementation 'jakarta.persistence:jakarta.persistence-api:3.1.0'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'com.mysql:mysql-connector-java'
runtimeOnly 'com.h2database:h2'

//mail
Expand All @@ -60,11 +59,7 @@ dependencies {
//redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
}
runtimeOnly 'com.h2database:h2'

//redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
}

tasks.named('test') {
useJUnitPlatform()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ public enum BaseExceptionResponseStatus implements ResponseStatus {
INVALID_USER_STATUS(5005, HttpStatus.BAD_REQUEST.value(), "잘못된 회원 status 값입니다."),
EMAIL_NOT_FOUND(5006, HttpStatus.BAD_REQUEST.value(), "존재하지 않는 이메일입니다."),
INVALID_PASSWORD(5007, HttpStatus.BAD_REQUEST.value(), "유효하지 않는 password입니다."),
INVALID_REFRESHTOKEN(5008, HttpStatus.BAD_REQUEST.value(), "유효하지 않는 토큰입니다.");


INVALID_PASSWORD(5007, HttpStatus.BAD_REQUEST.value(), "유효하지 않는 password입니다."),
UNABLE_TO_SEND_EMAIL(5008,HttpStatus.BAD_REQUEST.value(),"메일을 전송할 수 없습니다."),
INVALID_REFRESHTOKEN(5008, HttpStatus.BAD_REQUEST.value(), "유효하지 않는 토큰입니다."),
UNABLE_TO_SEND_EMAIL(5012,HttpStatus.BAD_REQUEST.value(),"메일을 전송할 수 없습니다."),
NO_SUCH_ALGORITHM(5009, HttpStatus.BAD_REQUEST.value(), "인증 번호 생성을 위한 알고리즘을 찾을 수 없습니다."),
AUTH_CODE_IS_NOT_SAME(5010, HttpStatus.BAD_REQUEST.value(), "인증 번호가 일치하지 않습니다."),
MEMBER_EXISTS(5011,HttpStatus.BAD_REQUEST.value(), "이미 존재하는 회원입니다.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@
import store.itpick.backend.common.response.BaseResponse;
import store.itpick.backend.dto.auth.LoginRequest;
import store.itpick.backend.dto.auth.LoginResponse;
import store.itpick.backend.dto.auth.RefreshRequest;
import store.itpick.backend.dto.auth.RefreshResponse;
import store.itpick.backend.dto.user.user.PostUserRequest;
import store.itpick.backend.dto.user.user.PostUserResponse;
import store.itpick.backend.service.UserService;
import store.itpick.backend.common.exception.UserException;

import static store.itpick.backend.common.response.status.BaseExceptionResponseStatus.INVALID_USER_VALUE;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

import static store.itpick.backend.common.response.status.BaseExceptionResponseStatus.*;
import static store.itpick.backend.common.response.status.BaseExceptionResponseStatus.INVALID_TOKEN;
import static store.itpick.backend.util.BindingResultUtils.getErrorMessages;

@Slf4j
Expand All @@ -44,7 +39,7 @@ public class UserController {
private final UserService userService;

@PostMapping("/refresh")
public BaseResponse<RefreshResponse> refresh(@Validated @RequestBody RefreshRequest refreshRequest) {
public BaseResponse<RefreshResponse> refresh(@Validated @RequestBody RefreshRequest refreshRequest) {
return new BaseResponse<>(userService.refresh(refreshRequest.getRefreshToken()));
}

Expand Down
16 changes: 1 addition & 15 deletions src/main/java/store/itpick/backend/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ public class UserService {
private final JwtProvider jwtProvider;


@Value("${secret.jwt-refresh-expired-in}")
private long JWT_REFRESH_EXPIRED_IN;






public LoginResponse login(LoginRequest authRequest) {
Expand Down Expand Up @@ -117,9 +111,7 @@ public PostUserResponse signUp(PostUserRequest postUserRequest) {
return new PostUserResponse(user.getUserId());
}

private void validateEmail(String email) {
if (userRepository.existsByEmailAndStatusIn(email, List.of("active", "dormant"))) {
throw new UserException(DUPLICATE_EMAIL);

public RefreshResponse refresh(String refreshToken){
// 만료 & 유효성 확인, 로그아웃 확인
if(jwtProvider.isExpiredToken(refreshToken) || refreshToken == null || refreshToken.isEmpty()){
Expand Down Expand Up @@ -236,11 +228,5 @@ public long getUserIdByEmail(String email) {
return userRepository.getUserByEmail(email).get().getUserId();
}

public void validationUserId(long userId, long header_userId) {
if (userId == header_userId) {
throw new UserException(TOKEN_MISMATCH);
}
}


}
43 changes: 34 additions & 9 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ spring:
on-profile: "localDB"

datasource:
# url: ${DATASOURCE_URL}
# username: ${DATASOURCE_USERNAME}
# password: ${DATASOURCE_PASSWORD}
url: jdbc:h2:tcp://localhost/~/itpick
username: sa
password:
# driver-class-name: com.mysql.cj.jdbc.Driver
url: ${DATASOURCE_URL}
username: ${DATASOURCE_USERNAME}
password: ${DATASOURCE_PASSWORD}
# url: jdbc:h2:tcp://localhost/~/itpick
# username: sa
## password:
driver-class-name: com.mysql.cj.jdbc.Driver
dbcp2:
validation-query: select 1
hikari:
driver-class-name: org.h2.Driver
# hikari:
# driver-class-name: org.h2.Driver
sql:
init:
platform: mysql
Expand All @@ -37,6 +37,26 @@ spring:
h2:
console:
enabled: true
mail:
host: smtp.gmail.com
port: 587
username: ${MAIL_USERNAME}
password: ${MAIL_PASSWORD}
properties:
mail:
smtp:
auth: true
starttls:
enable: true
required: true
connectiontimeout: 5000
timeout: 5000
writetimeout: 5000
auth-code-expiration-millis: 1800000
data:
redis:
host: localhost
port: 6379

---

Expand Down Expand Up @@ -87,6 +107,10 @@ spring:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQLDialect
h2:
console:
enabled: true


---

Expand Down Expand Up @@ -118,6 +142,7 @@ spring:
secret:
jwt-secret-key: ${JWT_SECRET_KEY}
jwt-expired-in: ${JWT_EXPIRED_IN}
jwt-refresh-expired-in: ${JWT_REFRESH_EXPIRED_IN}

---

Expand Down

0 comments on commit 9512a85

Please sign in to comment.