From c09fa9d5cf8fee6a4b7d7d43a25fb8048e6a0aa0 Mon Sep 17 00:00:00 2001 From: Arran Hobson Sayers Date: Fri, 10 Jan 2025 22:19:34 +0000 Subject: [PATCH] Fix user creation on proxy auth --- auth/proxy.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/auth/proxy.go b/auth/proxy.go index 9d140540..d6194e8f 100644 --- a/auth/proxy.go +++ b/auth/proxy.go @@ -22,7 +22,12 @@ type ProxyAuth struct { func (a ProxyAuth) Auth(r *http.Request, usr users.Store, setting *settings.Settings, srv *settings.Server) (*users.User, error) { username := r.Header.Get(a.Header) user, err := usr.Get(srv.Root, username) - if errors.Is(err, fbErrors.ErrNotExist) { + if err != nil { + // Return the error unless it is a user does not exist error + if !errors.Is(err, fbErrors.ErrNotExist) { + return nil, err + } + randomPasswordBytes := make([]byte, 32) //nolint:gomnd _, err = rand.Read(randomPasswordBytes) if err != nil { @@ -55,7 +60,7 @@ func (a ProxyAuth) Auth(r *http.Request, usr users.Store, setting *settings.Sett } } - return user, err + return user, nil } // LoginPage tells that proxy auth doesn't require a login page.