From 3b2bdd059a02b20654d19e2e9b04a3359d0e28cc Mon Sep 17 00:00:00 2001 From: Kenneth Jenkins <51246568+kenjenkins@users.noreply.github.com> Date: Tue, 5 Dec 2023 14:48:56 -0800 Subject: [PATCH] authenticate: getUserInfoData() cleanup (#4818) The Authenticate.getUserInfoData() method has an error return value, but always returns nil for this value. Let's remove this return value from the method signature. --- authenticate/handlers.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/authenticate/handlers.go b/authenticate/handlers.go index 333e05119..ef4a1bd24 100644 --- a/authenticate/handlers.go +++ b/authenticate/handlers.go @@ -98,12 +98,7 @@ func (a *Authenticate) mountDashboard(r *mux.Router) { sr.Path("/").Handler(a.requireValidSignatureOnRedirect(a.userInfo)) sr.Path("/sign_in").Handler(httputil.HandlerFunc(a.SignIn)) sr.Path("/device-enrolled").Handler(httputil.HandlerFunc(func(w http.ResponseWriter, r *http.Request) error { - userInfoData, err := a.getUserInfoData(r) - if err != nil { - return err - } - - handlers.DeviceEnrolled(userInfoData).ServeHTTP(w, r) + handlers.DeviceEnrolled(a.getUserInfoData(r)).ServeHTTP(w, r) return nil })) @@ -502,16 +497,11 @@ func (a *Authenticate) userInfo(w http.ResponseWriter, r *http.Request) error { return nil } - userInfoData, err := a.getUserInfoData(r) - if err != nil { - return err - } - - handlers.UserInfo(userInfoData).ServeHTTP(w, r) + handlers.UserInfo(a.getUserInfoData(r)).ServeHTTP(w, r) return nil } -func (a *Authenticate) getUserInfoData(r *http.Request) (handlers.UserInfoData, error) { +func (a *Authenticate) getUserInfoData(r *http.Request) handlers.UserInfoData { state := a.state.Load() s, err := a.getSessionFromCtx(r.Context()) @@ -527,7 +517,7 @@ func (a *Authenticate) getUserInfoData(r *http.Request) (handlers.UserInfoData, BrandingOptions: a.options.Load().BrandingOptions, } - return data, nil + return data } // revokeSession always clears the local session and tries to revoke the associated session stored in the