Skip to content

Commit

Permalink
refactor(auth): RequestHeader -> Body
Browse files Browse the repository at this point in the history
  • Loading branch information
qlido committed Apr 14, 2024
1 parent 4135010 commit 3788ce9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.project.bumawiki.domain.auth.presentation.dto.LoginReqestDto;
import com.project.bumawiki.domain.auth.presentation.dto.RefreshTokenRequestDto;
import com.project.bumawiki.domain.auth.presentation.dto.TokenResponseDto;
import com.project.bumawiki.domain.auth.service.AccessTokenRefreshService;
import com.project.bumawiki.domain.auth.service.UserSignUpOrUpdateService;
import com.project.bumawiki.domain.auth.service.CommandAuthService;

import lombok.RequiredArgsConstructor;

Expand All @@ -20,16 +21,15 @@
@RestController
@RequestMapping("/api/auth")
public class AuthController {
private final UserSignUpOrUpdateService userSignUpOrUpdateService;
private final AccessTokenRefreshService accessTokenRefreshService;
private final CommandAuthService commandAuthService;

@PostMapping("/oauth/bsm")
public TokenResponseDto userSignup(@RequestHeader("authCode") String authCode) throws IOException {
return TokenResponseDto.from(userSignUpOrUpdateService.execute(authCode));
public TokenResponseDto userSignup(@RequestBody LoginReqestDto loginReqestDto) throws IOException {
return TokenResponseDto.from(commandAuthService.login(loginReqestDto.accessToken()));
}

@PutMapping("/refresh/access")
public TokenResponseDto refreshAccessToken(@RequestHeader("refreshToken") String refreshToken) {
return TokenResponseDto.from(accessTokenRefreshService.execute(refreshToken));
public TokenResponseDto refreshAccessToken(@RequestBody RefreshTokenRequestDto refreshTokenRequestDto) {
return TokenResponseDto.from(commandAuthService.refresh(refreshTokenRequestDto.refreshToken()));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.project.bumawiki.domain.auth.presentation.dto;

public record AccessTokenRequestDto(
public record LoginReqestDto(
String accessToken
) {
}

0 comments on commit 3788ce9

Please sign in to comment.