Skip to content

Commit

Permalink
Merge pull request #150 from Team-HMH/modify/#123-delete-redis
Browse files Browse the repository at this point in the history
modify - delete redis
  • Loading branch information
kseysh authored Jun 8, 2024
2 parents ccc6916 + e097086 commit b416277
Show file tree
Hide file tree
Showing 11 changed files with 4 additions and 145 deletions.
32 changes: 1 addition & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

- **Language** : Java (jdk-17)
- **Web application Framework** : Spring boot (3.2.1), Spring Data JPA
- **DataBase** : MySql (8.1.0), Redis
- **DataBase** : MySql (8.1.0)
- **Cloud/Infra** : Aws EC2, RDS, code deploy
- **web server** : Tomcat, Nginx
- **Collaborative Tool** : Github, Slack, Notion
Expand All @@ -28,34 +28,4 @@
| <img width="300" alt="image" src="https://github.com/Team-HMH/HMH-Server/assets/76610340/ea57f67f-adcb-4abc-a198-7b962e61a6bc"> | <img width="300" alt="image" src="https://github.com/SOPT-33-iOS-Team-1/SOPKATHON_33-Server/assets/86935274/b1308faa-06cb-4818-878e-aeb8e17ac14c"> |
| [jumining](https://github.com/jumining) | [kseysh](https://github.com/kseysh) |

<br/>

## ✅ Convention



### 🚀Convention

- [💻 협업 컨벤션](https://hmhteam.notion.site/6fa22000670d4cf783559f7808c01d1a?pvs=4) <br>

### 🚀 Branch Strategy

- [💻 브랜치 전략](https://hmhteam.notion.site/9d8065b238c543b890ceeb9912966dd0?pvs=4)

<br/>

## 💾 ERD

![image](https://github.com/Team-HMH/HMH-Server/assets/69035864/f4b95b3d-6507-4d33-be41-8a4847bc076f)

<br>

<br>

## ⚙️ Architecture

![architecture](https://github.com/Team-HMH/HMH-Server/assets/69035864/e0eefac1-d8be-4a08-a3de-6e9786557042)


<br>

Empty file removed src/HMH-Server.iml
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public interface UserApi {

@Operation(summary = "로그아웃")
ResponseEntity<BaseResponse<?>> orderLogout(@UserId @Parameter(hidden = true) final Long userId);
ResponseEntity<BaseResponse<?>> orderLogout();

@Operation(summary = "유저 정보 불러오기")
ResponseEntity<BaseResponse<?>> orderGetUserInfo(@UserId @Parameter(hidden = true) final Long userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public class UserController implements UserApi{

@PostMapping("/logout")
@Override
public ResponseEntity<BaseResponse<?>> orderLogout(@UserId final Long userId) {
userService.logout(userId);
public ResponseEntity<BaseResponse<?>> orderLogout() {
return ResponseEntity
.status(UserSuccess.LOGOUT_SUCCESS.getHttpStatus())
.body(BaseResponse.success(UserSuccess.LOGOUT_SUCCESS, new EmptyJsonResponse()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import sopt.org.hmh.domain.auth.exception.AuthException;
import sopt.org.hmh.domain.auth.repository.OnboardingInfoRepository;
import sopt.org.hmh.domain.auth.repository.ProblemRepository;
import sopt.org.hmh.domain.challenge.domain.exception.ChallengeError;
import sopt.org.hmh.domain.challenge.domain.exception.ChallengeException;
import sopt.org.hmh.domain.user.domain.OnboardingInfo;
import sopt.org.hmh.domain.user.domain.OnboardingProblem;
import sopt.org.hmh.domain.user.domain.User;
Expand All @@ -22,30 +20,23 @@
import sopt.org.hmh.domain.user.domain.exception.UserException;
import sopt.org.hmh.domain.user.dto.response.UserInfoResponse;
import sopt.org.hmh.domain.user.repository.UserRepository;
import sopt.org.hmh.global.auth.redis.RedisManagerService;
import sopt.org.hmh.global.auth.social.SocialPlatform;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class UserService {

private final RedisManagerService redisManagerService;
private final UserRepository userRepository;
private final OnboardingInfoRepository onboardingInfoRepository;
private final ProblemRepository problemRepository;


@Transactional
public void withdraw(Long userId) {
redisManagerService.deleteRefreshToken(userId);
this.findByIdOrThrowException(userId).softDelete();
}

public void logout(Long userId) {
redisManagerService.deleteRefreshToken(userId);
}

public UserInfoResponse getUserInfo(Long userId) {
return UserInfoResponse.of(this.findByIdOrThrowException(userId));
}
Expand Down
16 changes: 1 addition & 15 deletions src/main/java/sopt/org/hmh/global/auth/jwt/JwtGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import sopt.org.hmh.global.auth.redis.RefreshToken;
import sopt.org.hmh.global.auth.redis.TokenRepository;

@Component
@RequiredArgsConstructor
Expand All @@ -25,29 +23,17 @@ public class JwtGenerator {
@Value("${jwt.refresh-token-expiration-time}")
private Long REFRESH_TOKEN_EXPIRATION_TIME;

private final TokenRepository tokenRepository;

public String generateToken(Long userId, boolean isRefreshToken) {
final Date now = generateNowDate();
final Date expiration = generateExpirationDate(isRefreshToken, now);

String token = Jwts.builder()
return Jwts.builder()
.setHeaderParam(Header.TYPE, Header.JWT_TYPE)
.setSubject(String.valueOf(userId))
.setIssuedAt(now)
.setExpiration(expiration)
.signWith(getSigningKey())
.compact();

if (isRefreshToken) {
tokenRepository.save(
RefreshToken.builder()
.userId(userId)
.token(token)
.expiration(REFRESH_TOKEN_EXPIRATION_TIME / 1000)
.build());
}
return token;
}

public JwtParser getJwtParser() {
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/sopt/org/hmh/global/auth/jwt/TokenService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,19 @@
import sopt.org.hmh.domain.auth.dto.response.ReissueResponse;
import sopt.org.hmh.global.auth.jwt.exception.JwtError;
import sopt.org.hmh.global.auth.jwt.exception.JwtException;
import sopt.org.hmh.global.auth.redis.RedisManagerService;

@Service
@RequiredArgsConstructor
public class TokenService {

private final JwtProvider jwtProvider;
private final JwtValidator jwtValidator;
private final RedisManagerService redisManagerService;

@Transactional
public ReissueResponse reissueToken(String refreshToken) {
String parsedRefreshToken = parseTokenString(refreshToken);
Long userId = jwtProvider.getSubject(parsedRefreshToken);
jwtValidator.validateRefreshToken(parsedRefreshToken);
redisManagerService.deleteRefreshToken(userId);
return ReissueResponse.of(jwtProvider.issueToken(userId));
}

Expand Down

This file was deleted.

25 changes: 0 additions & 25 deletions src/main/java/sopt/org/hmh/global/auth/redis/RefreshToken.java

This file was deleted.

This file was deleted.

32 changes: 0 additions & 32 deletions src/main/java/sopt/org/hmh/global/config/RedisConfig.java

This file was deleted.

0 comments on commit b416277

Please sign in to comment.