Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify - delete redis #150

Merged
merged 5 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading