Fixed production server login

This commit is contained in:
Eduard Urbach 2017-06-15 19:56:09 +02:00
parent 7178853b9a
commit 1790bce104
3 changed files with 16 additions and 3 deletions

View File

@ -30,7 +30,7 @@ func EnableGoogleLogin(app *aero.Application) {
conf := &oauth2.Config{ conf := &oauth2.Config{
ClientID: apiKeys.Google.ID, ClientID: apiKeys.Google.ID,
ClientSecret: apiKeys.Google.Secret, ClientSecret: apiKeys.Google.Secret,
RedirectURL: "https://beta.notify.moe/auth/google/callback", RedirectURL: "https://" + app.Config.Domain + "/auth/google/callback",
Scopes: []string{ Scopes: []string{
"https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.email",
}, },

View File

@ -2,8 +2,9 @@ package main
import "github.com/aerogo/aero" import "github.com/aerogo/aero"
func init() { // EnableLogin ...
// Authentication func EnableLogin(app *aero.Application) {
// Google
EnableGoogleLogin(app) EnableGoogleLogin(app)
// Session middleware // Session middleware

12
main.go
View File

@ -3,6 +3,7 @@ package main
import ( import (
"errors" "errors"
"net/http" "net/http"
"os"
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
@ -37,6 +38,14 @@ func main() {
return components.Layout(app, content) 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 // Ajax routes
app.Ajax("/", dashboard.Get) app.Ajax("/", dashboard.Get)
app.Ajax("/anime", search.Get) app.Ajax("/anime", search.Get)
@ -145,6 +154,9 @@ func main() {
return ctx.Text("Hello World") return ctx.Text("Hello World")
}) })
// Authentication
EnableLogin(app)
// Let's go // Let's go
app.Run() app.Run()
} }