Skip to content

Commit

Permalink
[Refactor] token valid API
Browse files Browse the repository at this point in the history
  • Loading branch information
uhyunglee committed May 4, 2024
1 parent 875036b commit 9ac26a3
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public boolean validateToken(String token){
log.info("Unsupported JWT token.");
} catch (IllegalArgumentException e) {
log.info("JWT token compact of handler are invalid.");
throw new BadRequestException(FAILED_TO_LOGIN_JWT);
}catch (Exception e) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public ResponseEntity<JsonResponse> validToken(){
String token = jwtService.getJwt();
boolean isValid = jwtService.validateToken(token);

return isValid ?
ResponseEntity.ok(new JsonResponse(true, 200, "유효한 토큰입니다", isValid))
: ResponseEntity.ok(new JsonResponse(false, 2004, "토큰을 확인하세요", null));
return ResponseEntity.ok(new JsonResponse(true, 200, "유효한 토큰입니다", isValid));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class UserController implements UserSwagger{
private final JwtService jwtService;

@PostMapping(value = "/user", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) //join
public ResponseEntity<JsonResponse> join(@RequestPart("user") UserDto.join req, @RequestPart(value ="image", required = false)MultipartFile image){
public ResponseEntity<JsonResponse> join(@RequestPart("user") UserDto.join req, @RequestParam(value ="image", required = false)MultipartFile image){
log.info("join");
String token = userService.joinUser(req, image);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

Expand All @@ -22,7 +23,7 @@ public ResponseEntity<JsonResponse> join(
@Parameter(
name = "image",
description = "프로필 이미지"
)@RequestPart(value = "image", required = false)MultipartFile image
)@RequestParam(value = "image", required = false)MultipartFile image
);
@Operation(summary = "유저 조회", description = "유저조회 API 호출")
@Parameter(name = "name", description="조회할 유저 이름",example = "김커먼", required = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class UserDto {
@AllArgsConstructor
@Data
public static class join{
@Schema(description = "회원가입할 사용자 email", example= "test@test.com")
@Schema(description = "회원가입할 사용자 email", example= "common@test.com")
private String email;
@Schema(description = "회원가입할 사용자 이름", example= "커먼")
private String name;
Expand Down

0 comments on commit 9ac26a3

Please sign in to comment.