Skip to content

Commit

Permalink
fix auth initialisation (micro#1630)
Browse files Browse the repository at this point in the history
  • Loading branch information
asim committed May 13, 2020
1 parent ebd5379 commit bba8c25
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions auth/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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,
}
}

0 comments on commit bba8c25

Please sign in to comment.