From e7c2946d32df154eba73a632cc9fda8f45766df5 Mon Sep 17 00:00:00 2001 From: garionion Date: Thu, 27 Feb 2025 12:55:34 +0100 Subject: [PATCH] refactor: adjust config paths and debug OAuth implementation --- main.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 4c33ad4..0110a88 100644 --- a/main.go +++ b/main.go @@ -61,7 +61,9 @@ var ( var db *sql.DB func main() { - cfgReader := config.NewConfReader("config").WithSearchDirs("./examples", ".") + var cfg Config + + cfgReader := config.NewConfReader("config").WithSearchDirs("./", ".") cfgErr := cfgReader.Read(&cfg) zapcfg := zap.NewProductionConfig() @@ -77,7 +79,6 @@ func main() { if cfgErr != nil { logger.Fatal("Failed to load config", zap.Error(cfgErr)) } - fmt.Println("test") logger.Info("Loaded config", zap.Any("config", cfg)) @@ -92,6 +93,7 @@ func main() { RedirectURL: fmt.Sprintf("http://localhost:%d/oauth/callback", cfg.Server.Port), Scopes: []string{"profile", "email"}, } + fmt.Println(oauthConfig) // Initialize database connection var dsn string @@ -126,7 +128,7 @@ func main() { // Initialize Echo e := echo.New() e.Use(middleware.Logger()) - e.Use(middleware.Recover()) + //e.Use(middleware.Recover()) e.Use(middleware.CORS()) // OAuth2 routes @@ -191,7 +193,7 @@ func handleOAuthCallback(c echo.Context) error { } logger.Info("OAuth token exchanged successfully", zap.String("access_token", token.AccessToken)) - + // Return HTML that stores the token and redirects to the main app html := fmt.Sprintf(` @@ -208,7 +210,7 @@ func handleOAuthCallback(c echo.Context) error { `, token.AccessToken) - + return c.HTML(http.StatusOK, html) }