diff --git a/auth/callback.go b/auth/callback.go index c217b93..0b02544 100644 --- a/auth/callback.go +++ b/auth/callback.go @@ -54,8 +54,6 @@ func NewCallbackHandler(c Config) http.HandlerFunc { // Getting now the userInfo user := User{} - - // var profile map[string]interface{} if err := idToken.Claims(&user); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -80,12 +78,12 @@ func NewCallbackHandler(c Config) http.HandlerFunc { // - by email address domain? //set tenant ID on application ID in App Metadata on user - if c.CallbackFunc != nil { - c.CallbackFunc(c, user) - } else { - // Redirect to logged in page - http.Redirect(w, r, "/user", http.StatusSeeOther) - } + // if c.CallbackFunc != nil { + // c.CallbackFunc(c, user) + // } else { + // Redirect to logged in page + http.Redirect(w, r, c.RedirectURL, http.StatusSeeOther) + // } } } diff --git a/auth/config.go b/auth/config.go index 7620186..a4c731b 100644 --- a/auth/config.go +++ b/auth/config.go @@ -10,21 +10,21 @@ type Config struct { ClientID string ClientSecret string CallbackURL string - CallbackFunc CallbackFunc + RedirectURL string } -func FromEnv(c CallbackFunc) Config { +func FromEnv() Config { return Config{ Domain: os.Getenv("AUTH_DOMAIN"), ClientID: os.Getenv("AUTH_CLIENT_ID"), ClientSecret: os.Getenv("AUTH_CLIENT_SECRET"), CallbackURL: os.Getenv("AUTH_CALLBACK_URL"), - CallbackFunc: c, + RedirectURL: "/user", } } func PrintConfig() { - fmt.Printf("%#v\n", FromEnv(nil)) + fmt.Printf("%#v\n", FromEnv()) } type CallbackFunc func(c Config, u User) error diff --git a/cmd/auth-demo/main.go b/cmd/auth-demo/main.go index 5967603..238ec4e 100644 --- a/cmd/auth-demo/main.go +++ b/cmd/auth-demo/main.go @@ -18,7 +18,7 @@ func StartServer() { auth.PrintConfig() s := jch_http.NewServer(negroni.New()). Static("/public/*filepath", http.Dir("public/")). - Service("", auth.Service(auth.FromEnv(nil))). + Service("", auth.Service(auth.FromEnv())). GET("/", "", http.HandlerFunc(HomeHandler)) port := os.Getenv("PORT")