From cd8a578dfef075d66aa5f674f87df79ba7c9d54a Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Sun, 25 Jun 2023 11:31:37 +0800 Subject: [PATCH] fix --- server/canteen/internal/svc/servicecontext.go | 3 +++ server/data-transfer/internal/svc/servicecontext.go | 3 +++ server/map-library/internal/svc/servicecontext.go | 3 +++ server/orders/internal/svc/servicecontext.go | 3 +++ server/product-templatev2/internal/svc/servicecontext.go | 3 +++ server/product/internal/svc/servicecontext.go | 3 +++ .../shopping-cart-confirmation/internal/svc/servicecontext.go | 3 +++ 7 files changed, 21 insertions(+) diff --git a/server/canteen/internal/svc/servicecontext.go b/server/canteen/internal/svc/servicecontext.go index dcd1d889..9712cabb 100644 --- a/server/canteen/internal/svc/servicecontext.go +++ b/server/canteen/internal/svc/servicecontext.go @@ -31,6 +31,9 @@ func NewServiceContext(c config.Config) *ServiceContext { func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { AuthKey := r.Header.Get("Authorization") + if AuthKey == "" { + return nil, nil + } if len(AuthKey) <= 50 { return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) } diff --git a/server/data-transfer/internal/svc/servicecontext.go b/server/data-transfer/internal/svc/servicecontext.go index 1a1a27a2..3236a65d 100644 --- a/server/data-transfer/internal/svc/servicecontext.go +++ b/server/data-transfer/internal/svc/servicecontext.go @@ -31,6 +31,9 @@ func NewServiceContext(c config.Config) *ServiceContext { func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { AuthKey := r.Header.Get("Authorization") + if AuthKey == "" { + return nil, nil + } if len(AuthKey) <= 50 { return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) } diff --git a/server/map-library/internal/svc/servicecontext.go b/server/map-library/internal/svc/servicecontext.go index ccf526be..5ee6e83a 100644 --- a/server/map-library/internal/svc/servicecontext.go +++ b/server/map-library/internal/svc/servicecontext.go @@ -31,6 +31,9 @@ func NewServiceContext(c config.Config) *ServiceContext { func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { AuthKey := r.Header.Get("Authorization") + if AuthKey == "" { + return nil, nil + } if len(AuthKey) <= 50 { return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) } diff --git a/server/orders/internal/svc/servicecontext.go b/server/orders/internal/svc/servicecontext.go index 99a7400a..61d8b459 100644 --- a/server/orders/internal/svc/servicecontext.go +++ b/server/orders/internal/svc/servicecontext.go @@ -31,6 +31,9 @@ func NewServiceContext(c config.Config) *ServiceContext { func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { AuthKey := r.Header.Get("Authorization") + if AuthKey == "" { + return nil, nil + } if len(AuthKey) <= 50 { return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) } diff --git a/server/product-templatev2/internal/svc/servicecontext.go b/server/product-templatev2/internal/svc/servicecontext.go index b12e9921..635b8dce 100644 --- a/server/product-templatev2/internal/svc/servicecontext.go +++ b/server/product-templatev2/internal/svc/servicecontext.go @@ -31,6 +31,9 @@ func NewServiceContext(c config.Config) *ServiceContext { func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { AuthKey := r.Header.Get("Authorization") + if AuthKey == "" { + return nil, nil + } if len(AuthKey) <= 50 { return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) } diff --git a/server/product/internal/svc/servicecontext.go b/server/product/internal/svc/servicecontext.go index b9157f3a..941adabc 100644 --- a/server/product/internal/svc/servicecontext.go +++ b/server/product/internal/svc/servicecontext.go @@ -31,6 +31,9 @@ func NewServiceContext(c config.Config) *ServiceContext { func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { AuthKey := r.Header.Get("Authorization") + if AuthKey == "" { + return nil, nil + } if len(AuthKey) <= 50 { return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) } diff --git a/server/shopping-cart-confirmation/internal/svc/servicecontext.go b/server/shopping-cart-confirmation/internal/svc/servicecontext.go index de8389d2..25e27c80 100644 --- a/server/shopping-cart-confirmation/internal/svc/servicecontext.go +++ b/server/shopping-cart-confirmation/internal/svc/servicecontext.go @@ -31,6 +31,9 @@ func NewServiceContext(c config.Config) *ServiceContext { func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { AuthKey := r.Header.Get("Authorization") + if AuthKey == "" { + return nil, nil + } if len(AuthKey) <= 50 { return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) }