Skip to content
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 @@ -27,14 +27,14 @@ public class UserController {

@PutMapping("/optional-info")
public ResponseEntity<?> putOptional(
@CookieValue(value = "accessToken", required = false) String accessToken,
@CookieValue(value = "refreshToken", required = false) String refreshToken,
@Valid @RequestBody UserUpdateRequest req) {

if (accessToken == null) {
if (refreshToken == null) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("accessToken not found in cookies");
}

AuthenticationResponse authenticationResponse = userService.putOptional(accessToken, req.phoneNumber(),
AuthenticationResponse authenticationResponse = userService.putOptional(refreshToken, req.phoneNumber(),
Boolean.TRUE.equals(req.consent()));

return ResponseEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public class UserService {
private final JwtUtil jwtUtil;

@Transactional
public AuthenticationResponse putOptional(String accessToken, String phoneNumber, boolean consent) {
public AuthenticationResponse putOptional(String refreshToken, String phoneNumber, boolean consent) {

Long userId = jwtUtil.getUserId(accessToken);;
String role = jwtUtil.getRole(accessToken);
Long userId = jwtUtil.getUserId(refreshToken);;
String role = jwtUtil.getRole(refreshToken);
AuthenticationResponse authenticationResponse;

User user = userRepository.findById(userId).orElseThrow(UserNotFoundException::new);
Expand All @@ -55,7 +55,7 @@ public AuthenticationResponse putOptional(String accessToken, String phoneNumber
60 * 60 * 1000L
);

tokenService.updateRefreshToken(userId, accessToken, newRefreshToken);
tokenService.updateRefreshToken(userId, refreshToken, newRefreshToken);

authenticationResponse = new AuthenticationResponse(newAccessToken, newRefreshToken);

Expand Down