diff --git a/cmd/root.go b/cmd/root.go index 9cab4c9..65eaba4 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,6 +1,7 @@ package cmd import ( + "errors" "os" "strings" "time" @@ -54,8 +55,10 @@ var rootCmd = &cobra.Command{ log.Info().Msg("Parsing users") users, usersErr := utils.GetUsers(config.Users, config.UsersFile) - if (len(users) == 0 || usersErr != nil) && !utils.OAuthConfigured(config) { - log.Fatal().Err(usersErr).Msg("Failed to parse users") + HandleError(usersErr, "Failed to parse users") + + if len(users) == 0 && !utils.OAuthConfigured(config) { + HandleError(errors.New("no users or OAuth configured"), "No users or OAuth configured") } // Create oauth whitelist diff --git a/internal/utils/utils.go b/internal/utils/utils.go index d7458a8..17f052f 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -104,7 +104,7 @@ func GetUsers(conf string, file string) (types.Users, error) { var users string if conf == "" && file == "" { - return types.Users{}, errors.New("no users provided") + return types.Users{}, nil } if conf != "" { @@ -128,7 +128,7 @@ func GetUsers(conf string, file string) (types.Users, error) { } func OAuthConfigured(config types.Config) bool { - return (config.GithubClientId != "" && config.GithubClientSecret != "") || (config.GoogleClientId != "" && config.GoogleClientSecret != "") || (config.GenericClientId != "" && config.GenericClientSecret != "") + return (config.GithubClientId != "" && config.GithubClientSecret != "") || (config.GoogleClientId != "" && config.GoogleClientSecret != "") || (config.GenericClientId != "" && config.GenericClientSecret != "") || (config.TailscaleClientId != "" && config.TailscaleClientSecret != "") } func GetTinyauthLabels(labels map[string]string) types.TinyauthLabels {