Skip to content

Commit

Permalink
fix(token): expire with seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
Matrix-X committed Sep 12, 2024
1 parent e876724 commit 6f7de86
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/middleware/webcustomerjwtauthmiddleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 6f7de86

Please sign in to comment.