Skip to content

Commit

Permalink
refactor: auth ์ ์šฉ
Browse files Browse the repository at this point in the history
  • Loading branch information
shb03323 committed Aug 3, 2023
1 parent 7676cf4 commit 480b542
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -18,7 +17,7 @@
import static org.springframework.http.HttpStatus.FOUND;

@RequiredArgsConstructor
@RequestMapping("/oauth")
@RequestMapping("/api/v1/oauth")
@RestController
public class OauthController {

Expand All @@ -34,11 +33,12 @@ public ResponseEntity<Void> redirectAuthCode(@PathVariable("oauthType") final Oa
return ResponseEntity.status(FOUND).build();
}

@PostMapping("/login/{oauthType}")
@GetMapping("/login/{oauthType}")
public ResponseEntity<Void> login(@PathVariable final OauthType oauthType,
@RequestParam final String code
) {
final String jwtToken = oauthService.login(oauthType, code);
System.out.println(jwtToken);

return ResponseEntity.ok()
.header(AUTHORIZATION, jwtToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import touch.baton.domain.oauth.controller.resolver.AuthRunnerPrincipal;
import touch.baton.domain.runner.Runner;
import touch.baton.domain.runner.controller.response.RunnerMyProfileResponse;
import touch.baton.domain.runner.controller.response.RunnerResponse;
import touch.baton.domain.runner.service.RunnerService;
import touch.baton.domain.runnerpost.controller.response.RunnerPostResponse;
import touch.baton.domain.runnerpost.service.RunnerPostService;

Expand All @@ -20,12 +20,9 @@
public class RunnerProfileController {

private final RunnerPostService runnerPostService;
private final RunnerService runnerService;

@GetMapping
public ResponseEntity<RunnerMyProfileResponse> read() {
// TODO: Auth ์ ์šฉ
Runner runner = runnerService.readRunnerWithMember(1L);
public ResponseEntity<RunnerMyProfileResponse> read(@AuthRunnerPrincipal final Runner runner) {
final RunnerResponse.Mine me = RunnerResponse.Mine.from(runner);
final List<RunnerPostResponse.Mine> runnerPosts = runnerPostService.readRunnerPostsByRunnerId(runner.getId()).stream()
.map(RunnerPostResponse.Mine::from)
Expand Down

0 comments on commit 480b542

Please sign in to comment.