Skip to content

Commit

Permalink
Merge pull request #107 from TEAM-MODDY/feat/#92
Browse files Browse the repository at this point in the history
#92 [feat] 로그아웃 api 기능 구현
  • Loading branch information
KWY0218 authored Jan 12, 2024
2 parents 69424ed + 82db9e6 commit 1836c8d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public enum SuccessCode {
POST_OFFER_SUCCESS(HttpStatus.OK, "제안서 작성 성공입니다."),
SEND_VERIFICATION_CODE_SUCCESS(HttpStatus.OK, "전화번호 인증 요청 성공입니다."),
FIND_REGION_LIST_SUCCESS(HttpStatus.OK, "희망 지역 리스트 조회 성공입니다."),
VERIFICATION_CODE_MATCH_SUCCESS(HttpStatus.OK, "전화번호 인증 성공입니다.");
VERIFICATION_CODE_MATCH_SUCCESS(HttpStatus.OK, "전화번호 인증 성공입니다."),
LOGOUT_SUCCESS(HttpStatus.OK, "로그아웃 성공입니다.");

private final HttpStatus httpStatus;
private final String message;
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/moddy/server/controller/auth/AuthController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.moddy.server.common.exception.enums.SuccessCode;
import com.moddy.server.common.util.SmsUtil;
import com.moddy.server.config.resolver.kakao.KakaoCode;
import com.moddy.server.config.resolver.user.UserId;
import com.moddy.server.controller.auth.dto.request.PhoneNumberRequestDto;
import com.moddy.server.controller.auth.dto.request.VerifyCodeRequestDto;
import com.moddy.server.controller.auth.dto.response.LoginResponseDto;
Expand Down Expand Up @@ -36,6 +37,7 @@

import java.util.List;

import static com.moddy.server.common.exception.enums.SuccessCode.LOGOUT_SUCCESS;
import static com.moddy.server.common.exception.enums.SuccessCode.SEND_VERIFICATION_CODE_SUCCESS;
import static com.moddy.server.common.exception.enums.SuccessCode.SOCIAL_LOGIN_SUCCESS;
import static com.moddy.server.common.exception.enums.SuccessCode.VERIFICATION_CODE_MATCH_SUCCESS;
Expand Down Expand Up @@ -140,4 +142,17 @@ public SuccessNonDataResponse verifyCode(@RequestBody VerifyCodeRequestDto verif
return SuccessNonDataResponse.success(VERIFICATION_CODE_MATCH_SUCCESS);
}

@Operation(summary = "로그아웃 API", description = "로그아웃 API")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "로그아웃 성공입니다."),
@ApiResponse(responseCode = "401", description = "인증 오류 입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "404", description = "존재하지 않는 유저입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@SecurityRequirement(name = "JWT Auth")
@PostMapping("/logout")
public SuccessNonDataResponse logout(@UserId Long userId) {
authService.logout(userId);
return SuccessNonDataResponse.success(LOGOUT_SUCCESS);
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/moddy/server/service/auth/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,8 @@ public void verifyCode(String phoneNumber, String verificationCode) {

userVerificationRepository.deleteByPhoneNumber(phoneNumber);
}

public void logout(Long userId) {
User user = userRepository.findById(userId).orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION));
}
}

0 comments on commit 1836c8d

Please sign in to comment.