From bba8c254d730da138eda7d2625f5cf2606183980 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Wed, 13 May 2020 17:35:57 +0100 Subject: [PATCH] fix auth initialisation (#1630) --- auth/service/service.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/auth/service/service.go b/auth/service/service.go index b8a163b0..90291257 100644 --- a/auth/service/service.go +++ b/auth/service/service.go @@ -17,11 +17,6 @@ import ( "github.com/micro/go-micro/v2/util/jitter" ) -// NewAuth returns a new instance of the Auth service -func NewAuth(opts ...auth.Option) auth.Auth { - return &svc{options: auth.NewOptions(opts...)} -} - // svc is the service implementation of the Auth interface type svc struct { options auth.Options @@ -45,6 +40,7 @@ func (s *svc) Init(opts ...auth.Option) { if s.options.Client == nil { s.options.Client = client.DefaultClient } + s.auth = pb.NewAuthService("go.micro.auth", s.options.Client) s.rule = pb.NewRulesService("go.micro.auth", s.options.Client) @@ -315,3 +311,18 @@ func serializeAccount(a *pb.Account) *auth.Account { Namespace: a.Namespace, } } + +// NewAuth returns a new instance of the Auth service +func NewAuth(opts ...auth.Option) auth.Auth { + options := auth.NewOptions(opts...) + + if options.Client == nil { + options.Client = client.DefaultClient + } + + return &svc{ + auth: pb.NewAuthService("go.micro.auth", options.Client), + rule: pb.NewRulesService("go.micro.auth", options.Client), + options: options, + } +}