diff --git a/google.go b/google.go index feff0d8f..42707433 100644 --- a/google.go +++ b/google.go @@ -30,7 +30,7 @@ func EnableGoogleLogin(app *aero.Application) { conf := &oauth2.Config{ ClientID: apiKeys.Google.ID, ClientSecret: apiKeys.Google.Secret, - RedirectURL: "https://beta.notify.moe/auth/google/callback", + RedirectURL: "https://" + app.Config.Domain + "/auth/google/callback", Scopes: []string{ "https://www.googleapis.com/auth/userinfo.email", }, diff --git a/login.go b/login.go index 6619f7de..e43e203e 100644 --- a/login.go +++ b/login.go @@ -2,8 +2,9 @@ package main import "github.com/aerogo/aero" -func init() { - // Authentication +// EnableLogin ... +func EnableLogin(app *aero.Application) { + // Google EnableGoogleLogin(app) // Session middleware diff --git a/main.go b/main.go index f82d0521..cf84de8b 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "errors" "net/http" + "os" "github.com/aerogo/aero" "github.com/animenotifier/arn" @@ -37,6 +38,14 @@ func main() { return components.Layout(app, content) } + // Production or Development mode + host, _ := os.Hostname() + isProduction := host != "home" + + if !isProduction { + app.Config.Domain = "beta.notify.moe" + } + // Ajax routes app.Ajax("/", dashboard.Get) app.Ajax("/anime", search.Get) @@ -145,6 +154,9 @@ func main() { return ctx.Text("Hello World") }) + // Authentication + EnableLogin(app) + // Let's go app.Run() }