From 6d0e88635be93a17f816defd4d8ef2a5eaa99c26 Mon Sep 17 00:00:00 2001 From: ginuerzh Date: Wed, 20 Sep 2023 22:53:36 +0800 Subject: [PATCH] update auther interface --- auth/auth.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/auth/auth.go b/auth/auth.go index 75aed07..56f48f6 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -4,7 +4,7 @@ import "context" // Authenticator is an interface for user authentication. type Authenticator interface { - Authenticate(ctx context.Context, user, password string) (ok bool, id string) + Authenticate(ctx context.Context, user, password string) (id string, ok bool) } type authenticatorGroup struct { @@ -17,18 +17,18 @@ func AuthenticatorGroup(authers ...Authenticator) Authenticator { } } -func (p *authenticatorGroup) Authenticate(ctx context.Context, user, password string) (bool, string) { +func (p *authenticatorGroup) Authenticate(ctx context.Context, user, password string) (string, bool) { if len(p.authers) == 0 { - return false, "" + return "", false } for _, auther := range p.authers { if auther == nil { continue } - if ok, id := auther.Authenticate(ctx, user, password); ok { - return ok, id + if id, ok := auther.Authenticate(ctx, user, password); ok { + return id, ok } } - return false, "" + return "", false }