|
| 1 | +package com.somemore.develop; |
| 2 | + |
| 3 | +import com.somemore.auth.jwt.domain.EncodedToken; |
| 4 | +import com.somemore.auth.jwt.domain.TokenType; |
| 5 | +import com.somemore.auth.jwt.domain.UserRole; |
| 6 | +import com.somemore.auth.jwt.generator.JwtGenerator; |
| 7 | +import com.somemore.global.common.response.ApiResponse; |
| 8 | +import lombok.RequiredArgsConstructor; |
| 9 | +import org.springframework.web.bind.annotation.GetMapping; |
| 10 | +import org.springframework.web.bind.annotation.PathVariable; |
| 11 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 12 | +import org.springframework.web.bind.annotation.RestController; |
| 13 | + |
| 14 | +@RestController |
| 15 | +@RequestMapping("/api/develop/token") |
| 16 | +@RequiredArgsConstructor |
| 17 | +public class TokenGenerateMachine { |
| 18 | + |
| 19 | + private final JwtGenerator jwtGenerator; |
| 20 | + |
| 21 | + @GetMapping("/volunteer/{volunteerId}") |
| 22 | + public ApiResponse<String> getVolunteerToken(@PathVariable String volunteerId) { |
| 23 | + EncodedToken token = jwtGenerator.generateToken(volunteerId, UserRole.VOLUNTEER.getAuthority(), TokenType.REFRESH); |
| 24 | + return ApiResponse.ok(token.value()); |
| 25 | + } |
| 26 | + |
| 27 | + @GetMapping("/center/{centerId}") |
| 28 | + public ApiResponse<String> getCenterToken(@PathVariable String centerId) { |
| 29 | + EncodedToken token = jwtGenerator.generateToken(centerId, UserRole.CENTER.getAuthority(), TokenType.REFRESH); |
| 30 | + return ApiResponse.ok(token.value()); |
| 31 | + } |
| 32 | +} |
0 commit comments