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
|
var db *sql.DB
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfgReader := config.NewConfReader("config").WithSearchDirs("./examples", ".")
|
var cfg Config
|
||||||
|
|
||||||
|
cfgReader := config.NewConfReader("config").WithSearchDirs("./", ".")
|
||||||
cfgErr := cfgReader.Read(&cfg)
|
cfgErr := cfgReader.Read(&cfg)
|
||||||
|
|
||||||
zapcfg := zap.NewProductionConfig()
|
zapcfg := zap.NewProductionConfig()
|
||||||
|
@ -77,7 +79,6 @@ func main() {
|
||||||
if cfgErr != nil {
|
if cfgErr != nil {
|
||||||
logger.Fatal("Failed to load config", zap.Error(cfgErr))
|
logger.Fatal("Failed to load config", zap.Error(cfgErr))
|
||||||
}
|
}
|
||||||
fmt.Println("test")
|
|
||||||
|
|
||||||
logger.Info("Loaded config", zap.Any("config", cfg))
|
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),
|
RedirectURL: fmt.Sprintf("http://localhost:%d/oauth/callback", cfg.Server.Port),
|
||||||
Scopes: []string{"profile", "email"},
|
Scopes: []string{"profile", "email"},
|
||||||
}
|
}
|
||||||
|
fmt.Println(oauthConfig)
|
||||||
|
|
||||||
// Initialize database connection
|
// Initialize database connection
|
||||||
var dsn string
|
var dsn string
|
||||||
|
@ -126,7 +128,7 @@ func main() {
|
||||||
// Initialize Echo
|
// Initialize Echo
|
||||||
e := echo.New()
|
e := echo.New()
|
||||||
e.Use(middleware.Logger())
|
e.Use(middleware.Logger())
|
||||||
e.Use(middleware.Recover())
|
//e.Use(middleware.Recover())
|
||||||
e.Use(middleware.CORS())
|
e.Use(middleware.CORS())
|
||||||
|
|
||||||
// OAuth2 routes
|
// OAuth2 routes
|
||||||
|
@ -191,7 +193,7 @@ func handleOAuthCallback(c echo.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info("OAuth token exchanged successfully", zap.String("access_token", token.AccessToken))
|
logger.Info("OAuth token exchanged successfully", zap.String("access_token", token.AccessToken))
|
||||||
|
|
||||||
// Return HTML that stores the token and redirects to the main app
|
// Return HTML that stores the token and redirects to the main app
|
||||||
html := fmt.Sprintf(`
|
html := fmt.Sprintf(`
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
@ -208,7 +210,7 @@ func handleOAuthCallback(c echo.Context) error {
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`, token.AccessToken)
|
`, token.AccessToken)
|
||||||
|
|
||||||
return c.HTML(http.StatusOK, html)
|
return c.HTML(http.StatusOK, html)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue