From 9f39049dd6024af5bca047df2dc3e697488b537d Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Sat, 12 Nov 2022 17:50:01 -0500 Subject: [PATCH] user --- pkg/auth/store.go | 5 +++++ pkg/auth/user.go | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/auth/store.go b/pkg/auth/store.go index 027a9c8..0c9374c 100644 --- a/pkg/auth/store.go +++ b/pkg/auth/store.go @@ -12,6 +12,7 @@ const ( ) type AuthStore interface { + User(UserID) *User } type authStore struct { @@ -48,3 +49,7 @@ func (a *Authenticator) newAuthStore(s storage.Store) (as *authStore, err error) return } + +func (s *authStore) User(uid UserID) *User { + return s.userMap[uid] +} diff --git a/pkg/auth/user.go b/pkg/auth/user.go index 219e285..88226d4 100644 --- a/pkg/auth/user.go +++ b/pkg/auth/user.go @@ -35,6 +35,10 @@ func (u *User) allowedToAuth() error { func (a *Authenticator) getOrCreateUser(c *Credential) (*User, error) { log.Debug().Interface("userdata", c.user.ProviderUserData()).Msg("getOrCreateUser") - panic("not implemented") - return &User{}, nil + u := a.store.User(c.UserID) + if u == nil { + return nil, errors.New("no such user) + } + + return u, nil }