From 6f7de868b254197f38d77f6d16e6b18234de8407 Mon Sep 17 00:00:00 2001 From: Matrix-X Date: Thu, 12 Sep 2024 22:13:04 +0800 Subject: [PATCH] fix(token): expire with seconds --- internal/middleware/webcustomerjwtauthmiddleware.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/middleware/webcustomerjwtauthmiddleware.go b/internal/middleware/webcustomerjwtauthmiddleware.go index d013458c..d29d1dee 100644 --- a/internal/middleware/webcustomerjwtauthmiddleware.go +++ b/internal/middleware/webcustomerjwtauthmiddleware.go @@ -6,6 +6,7 @@ import ( "PowerX/internal/types/errorx" "PowerX/internal/uc" "PowerX/internal/uc/powerx/crm/customerdomain" + fmt "PowerX/pkg/printx" "context" "github.com/golang-jwt/jwt/v4" "github.com/pkg/errors" @@ -35,6 +36,7 @@ func (m *WebCustomerJWTAuthMiddleware) Handle(next http.HandlerFunc) http.Handle return func(writer http.ResponseWriter, request *http.Request) { authorization := request.Header.Get("Authorization") + fmt.Dump(authorization) splits := strings.Split(authorization, "Bearer") if len(splits) != 2 { httpx.Error(writer, unAuth) @@ -46,6 +48,7 @@ func (m *WebCustomerJWTAuthMiddleware) Handle(next http.HandlerFunc) http.Handle token, err := jwt.ParseWithClaims(tokenString, &claims, func(token *jwt.Token) (interface{}, error) { return []byte(secret), nil }) + fmt.Dump(token, err) if err != nil || !token.Valid { if errors.Is(err, jwt.ErrTokenMalformed) { httpx.Error(writer, unAuth)