Skip to content

Commit

Permalink
✨ Feat: AuthController 토큰 검증 로직 추가 (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
win-luck committed Oct 16, 2023
1 parent 90c29f4 commit 7e6066d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,11 @@ public ApiResponse<HashMap<Long, String>> saveUser(CreateUserDto createUserDto)
map.put(userId, jwtTokenProvider.createToken(userId.toString()));
return ApiResponse.success(map, ResponseCode.USER_CREATE_SUCCESS.getMessage());
}

// 토큰 검증 (Jwt 토큰을 서버에 전송하여, 서버가 유효한 토큰인지 확인하고 True 혹은 예외 반환)
@Operation(summary = "[토큰 검증] 토큰 검증", description = "클라이언트가 가지고 있던 Jwt 토큰을 서버에 전송하여, 서버가 유효한 토큰인지 확인하고 OK 혹은 예외를 반환합니다.")
@GetMapping("/token")
public ApiResponse<Boolean> tokenCheck(@RequestHeader String jwtToken) {
return ApiResponse.success(jwtTokenProvider.validateToken(jwtToken), ResponseCode.TOKEN_CHECK_SUCCESS.getMessage());
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/diareat/diareat/util/api/ResponseCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public enum ResponseCode {
FOOD_FAVORITE_UPDATE_SUCCESS(HttpStatus.OK, true, "즐겨찾기 음식 수정 성공"),
FOOD_FAVORITE_DELETE_SUCCESS(HttpStatus.OK, true, "즐겨찾기 음식 삭제 성공"),

TOKEN_CHECK_SUCCESS(HttpStatus.OK, true, "토큰 검증 완료"),


// 201 Created
USER_CREATE_SUCCESS(HttpStatus.CREATED, true, "사용자 생성 성공"),
Expand Down

0 comments on commit 7e6066d

Please sign in to comment.