From e22c51f9f9f0597dc464eee8dfd87cc3ffba9f69 Mon Sep 17 00:00:00 2001 From: Roman Useinov Date: Sun, 16 Jan 2022 14:14:53 +0000 Subject: [PATCH] use DefaultConfig as base for JWT --- lib/tokens/jwt.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/tokens/jwt.go b/lib/tokens/jwt.go index 93c86b7..ca54f13 100644 --- a/lib/tokens/jwt.go +++ b/lib/tokens/jwt.go @@ -16,16 +16,17 @@ import ( ) func Middleware(secret []byte) echo.MiddlewareFunc { - config := middleware.JWTConfig{ - ContextKey: "UserJwt", - SigningKey: secret, - SuccessHandler: func(c echo.Context) { - token := c.Get("UserJwt").(*jwt.Token) - claims := token.Claims.(jwt.MapClaims) - c.Set("UserID", claims["id"]) + config := middleware.DefaultJWTConfig + + config.ContextKey = "UserJwt" + config.SigningKey = secret + config.SuccessHandler = func(c echo.Context) { + token := c.Get("UserJwt").(*jwt.Token) + claims := token.Claims.(jwt.MapClaims) + c.Set("UserID", claims["id"]) - }, } + return middleware.JWTWithConfig(config) }