-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,6 +147,7 @@ as either "provider" or ":provider". | |
See https://github.com/markbates/goth/examples/main.go to see this in action. | ||
*/ | ||
var CompleteUserAuth = func(res http.ResponseWriter, req *http.Request) (goth.User, error) { | ||
defer Logout(res, req) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
markbates
Author
Owner
|
||
if !keySet && defaultStore == Store { | ||
fmt.Println("goth/gothic: no SESSION_SECRET environment variable is set. The default cookie store is not available and any calls will fail. Ignore this warning if you are using a different store.") | ||
} | ||
|
@@ -166,8 +167,6 @@ var CompleteUserAuth = func(res http.ResponseWriter, req *http.Request) (goth.Us | |
return goth.User{}, err | ||
} | ||
|
||
defer Logout(res, req) | ||
|
||
sess, err := provider.UnmarshalSession(value) | ||
if err != nil { | ||
return goth.User{}, err | ||
|
@@ -222,12 +221,7 @@ func validateState(req *http.Request, sess goth.Session) error { | |
|
||
// Logout invalidates a user session. | ||
func Logout(res http.ResponseWriter, req *http.Request) error { | ||
providerName, err := GetProviderName(req) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
session, err := Store.Get(req, providerName+SessionName) | ||
session, err := Store.Get(req, SessionName) | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -287,15 +281,15 @@ func getProviderName(req *http.Request) (string, error) { | |
} | ||
|
||
func storeInSession(key string, value string, req *http.Request, res http.ResponseWriter) error { | ||
session, _ := Store.Get(req, key+SessionName) | ||
session, _ := Store.Get(req, SessionName) | ||
|
||
session.Values[key] = value | ||
|
||
return session.Save(req, res) | ||
} | ||
|
||
func getFromSession(key string, req *http.Request) (string, error) { | ||
session, _ := Store.Get(req, key+SessionName) | ||
session, _ := Store.Get(req, SessionName) | ||
value := session.Values[key] | ||
if value == nil { | ||
return "", errors.New("could not find a matching session for this request") | ||
|
@markbates why was this moved up to again (after being moved down to UnmarshalSession with commit 86ca064 in Oct 2017?
It makes my setup unusable. Might be that I'm force-feeding it with gin but if I move the deferred logout down it works.
It causes (when it at the first line of the func) 2 cookies to be sent (both named
_gothic_session
) in the same response:(first one is 185 chars long and the 2nd one is 805 chars long)
Looks like this confuses my browser (chrome, firefox).