refactor: adjust config paths and debug OAuth implementation
This commit is contained in:
parent
77538a7dfd
commit
e7c2946d32
1 changed files with 7 additions and 5 deletions
12
main.go
12
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(`
|
||||
<!DOCTYPE html>
|
||||
|
@ -208,7 +210,7 @@ func handleOAuthCallback(c echo.Context) error {
|
|||
</body>
|
||||
</html>
|
||||
`, token.AccessToken)
|
||||
|
||||
|
||||
return c.HTML(http.StatusOK, html)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue