fix: fix cli imports

This commit is contained in:
Stavros
2026-04-29 19:28:40 +03:00
parent b426a1529e
commit 97d58b376d
4 changed files with 13 additions and 14 deletions
+3 -3
View File
@@ -73,7 +73,7 @@ func generateTotpCmd() *cli.Command {
docker = true docker = true
} }
if user.TotpSecret != "" { if user.TOTPSecret != "" {
return fmt.Errorf("user already has a TOTP secret") return fmt.Errorf("user already has a TOTP secret")
} }
@@ -102,14 +102,14 @@ func generateTotpCmd() *cli.Command {
qrterminal.GenerateWithConfig(key.URL(), config) qrterminal.GenerateWithConfig(key.URL(), config)
user.TotpSecret = secret user.TOTPSecret = secret
// If using docker escape re-escape it // If using docker escape re-escape it
if docker { if docker {
user.Password = strings.ReplaceAll(user.Password, "$", "$$") user.Password = strings.ReplaceAll(user.Password, "$", "$$")
} }
tlog.App.Info().Str("user", fmt.Sprintf("%s:%s:%s", user.Username, user.Password, user.TotpSecret)).Msg("Add the totp secret to your authenticator app then use the verify command to ensure everything is working correctly.") tlog.App.Info().Str("user", fmt.Sprintf("%s:%s:%s", user.Username, user.Password, user.TOTPSecret)).Msg("Add the totp secret to your authenticator app then use the verify command to ensure everything is working correctly.")
return nil return nil
}, },
+4 -4
View File
@@ -5,7 +5,7 @@ import (
"charm.land/huh/v2" "charm.land/huh/v2"
"github.com/tinyauthapp/tinyauth/internal/bootstrap" "github.com/tinyauthapp/tinyauth/internal/bootstrap"
"github.com/tinyauthapp/tinyauth/internal/config" "github.com/tinyauthapp/tinyauth/internal/model"
"github.com/tinyauthapp/tinyauth/internal/utils/loaders" "github.com/tinyauthapp/tinyauth/internal/utils/loaders"
"github.com/tinyauthapp/tinyauth/internal/utils/tlog" "github.com/tinyauthapp/tinyauth/internal/utils/tlog"
@@ -14,7 +14,7 @@ import (
) )
func main() { func main() {
tConfig := config.NewDefaultConfiguration() tConfig := model.NewDefaultConfiguration()
loaders := []cli.ResourceLoader{ loaders := []cli.ResourceLoader{
&loaders.FileLoader{}, &loaders.FileLoader{},
@@ -108,11 +108,11 @@ func main() {
} }
} }
func runCmd(cfg config.Config) error { func runCmd(cfg model.Config) error {
logger := tlog.NewLogger(cfg.Log) logger := tlog.NewLogger(cfg.Log)
logger.Init() logger.Init()
tlog.App.Info().Str("version", config.Version).Msg("Starting tinyauth") tlog.App.Info().Str("version", model.Version).Msg("Starting tinyauth")
app := bootstrap.NewBootstrapApp(cfg) app := bootstrap.NewBootstrapApp(cfg)
+2 -2
View File
@@ -95,7 +95,7 @@ func verifyUserCmd() *cli.Command {
return fmt.Errorf("password is incorrect: %w", err) return fmt.Errorf("password is incorrect: %w", err)
} }
if user.TotpSecret == "" { if user.TOTPSecret == "" {
if tCfg.Totp != "" { if tCfg.Totp != "" {
tlog.App.Warn().Msg("User does not have TOTP secret") tlog.App.Warn().Msg("User does not have TOTP secret")
} }
@@ -103,7 +103,7 @@ func verifyUserCmd() *cli.Command {
return nil return nil
} }
ok := totp.Validate(tCfg.Totp, user.TotpSecret) ok := totp.Validate(tCfg.Totp, user.TOTPSecret)
if !ok { if !ok {
return fmt.Errorf("TOTP code incorrect") return fmt.Errorf("TOTP code incorrect")
+4 -5
View File
@@ -3,9 +3,8 @@ package main
import ( import (
"fmt" "fmt"
"github.com/tinyauthapp/tinyauth/internal/config"
"github.com/tinyauthapp/paerser/cli" "github.com/tinyauthapp/paerser/cli"
"github.com/tinyauthapp/tinyauth/internal/model"
) )
func versionCmd() *cli.Command { func versionCmd() *cli.Command {
@@ -15,9 +14,9 @@ func versionCmd() *cli.Command {
Configuration: nil, Configuration: nil,
Resources: nil, Resources: nil,
Run: func(_ []string) error { Run: func(_ []string) error {
fmt.Printf("Version: %s\n", config.Version) fmt.Printf("Version: %s\n", model.Version)
fmt.Printf("Commit Hash: %s\n", config.CommitHash) fmt.Printf("Commit Hash: %s\n", model.CommitHash)
fmt.Printf("Build Timestamp: %s\n", config.BuildTimestamp) fmt.Printf("Build Timestamp: %s\n", model.BuildTimestamp)
return nil return nil
}, },
} }