Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jwt 추출 변경 #1

Open
ShinJam opened this issue Jan 18, 2022 · 0 comments
Open

jwt 추출 변경 #1

ShinJam opened this issue Jan 18, 2022 · 0 comments

Comments

@ShinJam
Copy link
Owner

ShinJam commented Jan 18, 2022

AS-IS

func ExtractTokenMetadata(c *fiber.Ctx) (*TokenMetadata, error) { 함수에서 token을 추출 하고 있다.

TO-BE

func JWTProtected() func(*fiber.Ctx) error { 에서
jwtware.New(config ...jwtware.Config) func(*fiber.Ctx) error 를 사용하고 있기 때문에
Locals에서 뽑을 수가 있다.

user := c.Locals("user").(*jwt.Token)
claims := user.Claims.(jwt.MapClaims)
name := claims["name"].(string)

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant