-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: fix Swagger api call api call 과정에서 cors 문제 해결 * fix: Fix auth redirect api
- Loading branch information
Showing
6 changed files
with
139 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 44 additions & 27 deletions
71
src/main/java/com/universe/uni/controller/AuthController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,72 @@ | ||
package com.universe.uni.controller; | ||
|
||
import com.universe.uni.controller.docs.AuthControllerContract; | ||
import com.universe.uni.dto.AuthTokenDto; | ||
import com.universe.uni.dto.request.AuthRequestDto; | ||
import com.universe.uni.service.AuthServiceContract; | ||
|
||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.universe.uni.controller.docs.AuthControllerContract; | ||
import com.universe.uni.dto.AuthTokenDto; | ||
import com.universe.uni.dto.request.AuthRequestDto; | ||
import com.universe.uni.service.AuthServiceContract; | ||
import java.net.MalformedURLException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.springframework.web.client.RestTemplate; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("auth") | ||
public class AuthController implements AuthControllerContract { | ||
|
||
private final AuthServiceContract authService; | ||
private final AuthServiceContract authService; | ||
|
||
@PostMapping("kakao") | ||
@Override | ||
public AuthTokenDto authByKakao(@RequestBody AuthRequestDto request) { | ||
return authService.authWithKakao(request.code()); | ||
} | ||
@PostMapping("kakao") | ||
@Override | ||
public AuthTokenDto authByKakao(@RequestBody AuthRequestDto request) { | ||
return authService.authWithKakao(request.code()); | ||
} | ||
|
||
@PostMapping("google") | ||
@Override | ||
public AuthTokenDto authByGoogle(@RequestBody AuthRequestDto request) { | ||
return authService.authWithGoogle(request.code()); | ||
} | ||
@PostMapping("google") | ||
@Override | ||
public AuthTokenDto authByGoogle(@RequestBody AuthRequestDto request) { | ||
return authService.authWithGoogle(request.code()); | ||
} | ||
|
||
@PostMapping("apple") | ||
@PostMapping("apple") | ||
@Override | ||
public AuthTokenDto authByApple(@RequestBody AuthRequestDto request) { | ||
return authService.authWithAppleUser(request.code()); | ||
} | ||
public AuthTokenDto authByApple(@RequestBody AuthRequestDto request) { | ||
return authService.authWithAppleUser(request.code()); | ||
} | ||
|
||
@GetMapping("kakao/callback") | ||
@GetMapping("kakao/callback") | ||
@Override | ||
public AuthRequestDto redirectKakaoAuth(@RequestParam(name = "code") String authenticationCode) { | ||
return new AuthRequestDto(authenticationCode); | ||
} | ||
public AuthTokenDto redirectKakaoAuth( | ||
@RequestParam(name = "code") String authenticationCode | ||
) { | ||
return authService.authWithKakaoCode(authenticationCode); | ||
} | ||
|
||
@GetMapping("google/callback") | ||
@GetMapping("google/callback") | ||
@Override | ||
public AuthRequestDto redirectGoogleAuth(@RequestParam(name = "code") String authenticationCode) { | ||
return new AuthRequestDto(authenticationCode); | ||
} | ||
public AuthTokenDto redirectGoogleAuth( | ||
@RequestParam(name = "code") String authenticationCode | ||
) { | ||
return authService.authWithGoogleCode(authenticationCode); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters