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

[Refactor] validate token api #115

Merged
merged 2 commits into from
May 4, 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
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
Loading