From 533440dac5cfffd9bfeb8e07e8872d90578dca92 Mon Sep 17 00:00:00 2001 From: marcos Date: Mon, 18 Dec 2017 14:11:13 -0300 Subject: [PATCH] Fix issue when validating providers for playground when creating a new session --- handlers/new_session.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/handlers/new_session.go b/handlers/new_session.go index cdae21d..ff5e684 100644 --- a/handlers/new_session.go +++ b/handlers/new_session.go @@ -21,10 +21,17 @@ type NewSessionResponse struct { } func NewSession(rw http.ResponseWriter, req *http.Request) { + playground := core.PlaygroundFindByDomain(req.Host) + if playground == nil { + log.Printf("Playground for domain %s was not found!", req.Host) + rw.WriteHeader(http.StatusBadRequest) + return + } + req.ParseForm() userId := "" - if len(config.Providers) > 0 { + if len(config.Providers[playground.Id]) > 0 { cookie, err := ReadCookie(req) if err != nil { // User it not a human @@ -53,13 +60,6 @@ func NewSession(rw http.ResponseWriter, req *http.Request) { } - playground := core.PlaygroundFindByDomain(req.Host) - if playground == nil { - log.Printf("Playground for domain %s was not found!", req.Host) - rw.WriteHeader(http.StatusBadRequest) - return - } - var duration time.Duration if reqDur != "" { d, err := time.ParseDuration(reqDur)