mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 04:35:40 +00:00
fix: handle user parse errors correctly
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -54,8 +55,10 @@ var rootCmd = &cobra.Command{
|
|||||||
log.Info().Msg("Parsing users")
|
log.Info().Msg("Parsing users")
|
||||||
users, usersErr := utils.GetUsers(config.Users, config.UsersFile)
|
users, usersErr := utils.GetUsers(config.Users, config.UsersFile)
|
||||||
|
|
||||||
if (len(users) == 0 || usersErr != nil) && !utils.OAuthConfigured(config) {
|
HandleError(usersErr, "Failed to parse users")
|
||||||
log.Fatal().Err(usersErr).Msg("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
|
// Create oauth whitelist
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ func GetUsers(conf string, file string) (types.Users, error) {
|
|||||||
var users string
|
var users string
|
||||||
|
|
||||||
if conf == "" && file == "" {
|
if conf == "" && file == "" {
|
||||||
return types.Users{}, errors.New("no users provided")
|
return types.Users{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if conf != "" {
|
if conf != "" {
|
||||||
@@ -128,7 +128,7 @@ func GetUsers(conf string, file string) (types.Users, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func OAuthConfigured(config types.Config) bool {
|
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 {
|
func GetTinyauthLabels(labels map[string]string) types.TinyauthLabels {
|
||||||
|
|||||||
Reference in New Issue
Block a user