Skip to content

Commit 3268594

Browse files
committed
feat: 개발용 토큰 발급기
- 봉사자 - 기관
1 parent 1337e75 commit 3268594

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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

Comments
 (0)