Skip to content

Commit

Permalink
chore: 테스트용 토큰 발급 API 응답 형식 변경 (#47)
Browse files Browse the repository at this point in the history
* feat: 백신 접종내역 생성

* feat: unclassified Vaccination Discord Webhook

* chore: 테스트용 토큰 발급 API 구현 (#45)

* chore: 테스트용 토큰 발급 API 구현

---------

Co-authored-by: Haebin <[email protected]>
  • Loading branch information
whereami2048 and h-beeen authored Jan 6, 2025
1 parent 96749e9 commit a225b68
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/kotlin/kr/co/vacgom/api/TestController.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package kr.co.vacgom.api

import kr.co.vacgom.api.auth.oauth.enums.SocialLoginProvider
import kr.co.vacgom.api.global.common.dto.BaseResponse
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
Expand All @@ -19,25 +20,26 @@ class TestController(
) {

@PostMapping
fun test(@RequestParam tokenType: String): ResponseEntity<String> {
fun test(@RequestParam tokenType: String): BaseResponse<String> {
val user = userRepository.findAll()[0]

when (tokenType) {
"ACCESS" -> {
val accessToken = userTokenService.createAccessToken(user.id, user.role)
return ResponseEntity.ok(accessToken)
return BaseResponse.success(accessToken)
}
"REFRESH" -> {
val refreshToken = userTokenService.createRefreshToken(user.id)
return ResponseEntity.ok(refreshToken)
return BaseResponse.success(refreshToken)

}
"REGISTER" -> {
val socialId = "testSocialId${Random(System.currentTimeMillis()).nextInt()}"
val registerToken = userTokenService.createRegisterToken(socialId, SocialLoginProvider.KAKAO.name)
return ResponseEntity.ok(registerToken)
return BaseResponse.success(registerToken)
}
}

return ResponseEntity.internalServerError().build()
return BaseResponse.fail("토큰 타입이 올바르지 않습니다.")
}
}

0 comments on commit a225b68

Please sign in to comment.