-
Notifications
You must be signed in to change notification settings - Fork 2
feat: 회원 탈퇴 구현 #178
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
feat: 회원 탈퇴 구현 #178
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,4 +24,6 @@ default User getById(Long userId) { | |
| return findById(userId) | ||
| .orElseThrow(() -> UserNotFoundException.withDetail("userId: " + userId)); | ||
| } | ||
|
|
||
| void delete(User user); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A삭제는 보통
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 음 결국 내부적으로 처리하는 내용은 같아서 취향차이인거같습니다. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,6 @@ | |
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import in.koreatech.koin.global.auth.JwtProvider; | ||
| import in.koreatech.koin.global.auth.exception.AuthException; | ||
| import in.koreatech.koin.domain.user.dto.UserLoginRequest; | ||
| import in.koreatech.koin.domain.user.dto.UserLoginResponse; | ||
| import in.koreatech.koin.domain.user.dto.UserTokenRefreshRequest; | ||
|
|
@@ -17,6 +15,8 @@ | |
| import in.koreatech.koin.domain.user.model.UserToken; | ||
| import in.koreatech.koin.domain.user.repository.UserRepository; | ||
| import in.koreatech.koin.domain.user.repository.UserTokenRepository; | ||
| import in.koreatech.koin.global.auth.JwtProvider; | ||
| import in.koreatech.koin.global.auth.exception.AuthException; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Service | ||
|
|
@@ -62,11 +62,17 @@ public UserTokenRefreshResponse refresh(UserTokenRefreshRequest request) { | |
| return UserTokenRefreshResponse.of(accessToken, userToken.getRefreshToken()); | ||
| } | ||
|
|
||
| private static String getUserId(String refreshToken) { | ||
| private String getUserId(String refreshToken) { | ||
| String[] split = refreshToken.split("-"); | ||
| if (split.length == 0) { | ||
| throw new AuthException("올바르지 않은 인증 토큰입니다. refreshToken: " + refreshToken); | ||
| } | ||
| return split[split.length - 1]; | ||
| } | ||
|
Comment on lines
65
to
71
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이게 어쩌다 붙었나... 모르겠지만 눈에 보여서 제거했습니다 |
||
|
|
||
| @Transactional | ||
| public void withdraw(Long userId) { | ||
| User user = userRepository.getById(userId); | ||
| userRepository.delete(user); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,7 +47,6 @@ void userLoginSuccess() { | |
|
|
||
| ExtractableResponse<Response> response = RestAssured | ||
| .given() | ||
| .log().all() | ||
| .body(""" | ||
| { | ||
| "email": "test@koreatech.ac.kr", | ||
|
|
@@ -56,10 +55,8 @@ void userLoginSuccess() { | |
| """) | ||
| .contentType(ContentType.JSON) | ||
| .when() | ||
| .log().all() | ||
| .post("/user/login") | ||
| .then() | ||
| .log().all() | ||
| .statusCode(HttpStatus.CREATED.value()) | ||
| .extract(); | ||
|
|
||
|
|
@@ -96,7 +93,6 @@ void userLogoutSuccess() { | |
|
|
||
| ExtractableResponse<Response> response = RestAssured | ||
| .given() | ||
| .log().all() | ||
| .body(""" | ||
| { | ||
| "email": "test@koreatech.ac.kr", | ||
|
|
@@ -105,22 +101,17 @@ void userLogoutSuccess() { | |
| """) | ||
| .contentType(ContentType.JSON) | ||
| .when() | ||
| .log().all() | ||
| .post("/user/login") | ||
| .then() | ||
| .log().all() | ||
| .statusCode(HttpStatus.CREATED.value()) | ||
| .extract(); | ||
|
|
||
| RestAssured | ||
| .given() | ||
| .log().all() | ||
| .header("Authorization", "Bearer " + response.jsonPath().getString("token")) | ||
| .when() | ||
| .log().all() | ||
| .post("/user/logout") | ||
| .then() | ||
| .log().all() | ||
| .statusCode(HttpStatus.OK.value()) | ||
| .extract(); | ||
|
|
||
|
Comment on lines
109
to
117
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A앞으로 올리는 PR은
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네~! 불필요하게 로그가 많이 찍히는것 같아요~ |
||
|
|
@@ -147,7 +138,6 @@ void userRefreshToken() { | |
|
|
||
| ExtractableResponse<Response> response = RestAssured | ||
| .given() | ||
| .log().all() | ||
| .body(""" | ||
| { | ||
| "email": "test@koreatech.ac.kr", | ||
|
|
@@ -156,25 +146,20 @@ void userRefreshToken() { | |
| """) | ||
| .contentType(ContentType.JSON) | ||
| .when() | ||
| .log().all() | ||
| .post("/user/login") | ||
| .then() | ||
| .log().all() | ||
| .statusCode(HttpStatus.CREATED.value()) | ||
| .extract(); | ||
|
|
||
| RestAssured | ||
| .given() | ||
| .log().all() | ||
| .body( | ||
| Map.of("refresh_token", response.jsonPath().getString("refresh_token")) | ||
| ) | ||
| .contentType(ContentType.JSON) | ||
| .when() | ||
| .log().all() | ||
| .post("/user/refresh") | ||
| .then() | ||
| .log().all() | ||
| .statusCode(HttpStatus.OK.value()) | ||
| .extract(); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A
넵 저는 개인적으로 어드민 기능 구현 시 적용하는 것이 좋아 보입니다.
나중에 번거로울 수는 있지만 사용하지 않는 기능에 대해 코드를 작성해두는 것은 코드를 복잡하게 만들 우려가 있다고 생각합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A
저도 @filter가 필요해질 때 적용하는 게 좋다고 생각합니다.