removed callbackfunc, it was unnecessary

This commit is contained in:
Colin Henry 2019-09-30 11:46:13 -07:00
parent 291a3f80c3
commit ea921a3b65
3 changed files with 11 additions and 13 deletions

View File

@ -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)
// }
}
}

View File

@ -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

View File

@ -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")