Skip to content

Commit

Permalink
chore: 테스트용 토큰 발급 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
whereami2048 committed Jan 6, 2025
1 parent 2f4e0f3 commit 78158de
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Binary file removed dump.rdb
Binary file not shown.
27 changes: 23 additions & 4 deletions src/main/kotlin/kr/co/vacgom/api/TestController.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package kr.co.vacgom.api

import kr.co.vacgom.api.auth.oauth.enums.SocialLoginProvider
import kr.co.vacgom.api.global.presentation.GlobalPath.BASE_V3
import kr.co.vacgom.api.user.application.UserTokenService
import kr.co.vacgom.api.user.repository.UserRepository
import org.springframework.http.ResponseEntity
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
import kotlin.random.Random

@RestController
@RequestMapping(BASE_V3 + "/TEST")
Expand All @@ -16,9 +19,25 @@ class TestController(
) {

@PostMapping
fun test(): ResponseEntity<String> {
val user = userRepository.findAll().get(0)
val accessToken = userTokenService.createAccessToken(user.id, user.role)
return ResponseEntity.ok(accessToken)
fun test(@RequestParam tokenType: String): ResponseEntity<String> {
val user = userRepository.findAll()[0]

when (tokenType) {
"ACCESS" -> {
val accessToken = userTokenService.createAccessToken(user.id, user.role)
return ResponseEntity.ok(accessToken)
}
"REFRESH" -> {
val refreshToken = userTokenService.createRefreshToken(user.id)
return ResponseEntity.ok(refreshToken)
}
"REGISTER" -> {
val socialId = "testSocialId${Random(System.currentTimeMillis()).nextInt()}"
val registerToken = userTokenService.createRegisterToken(socialId, SocialLoginProvider.KAKAO.name)
return ResponseEntity.ok(registerToken)
}
}

return ResponseEntity.internalServerError().build()
}
}

0 comments on commit 78158de

Please sign in to comment.