aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/markbates/goth/gothic/gothic.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/markbates/goth/gothic/gothic.go')
-rw-r--r--vendor/github.com/markbates/goth/gothic/gothic.go24
1 files changed, 11 insertions, 13 deletions
diff --git a/vendor/github.com/markbates/goth/gothic/gothic.go b/vendor/github.com/markbates/goth/gothic/gothic.go
index bea87d963d..ea4e1e0db8 100644
--- a/vendor/github.com/markbates/goth/gothic/gothic.go
+++ b/vendor/github.com/markbates/goth/gothic/gothic.go
@@ -245,19 +245,6 @@ var GetProviderName = getProviderName
func getProviderName(req *http.Request) (string, error) {
- // get all the used providers
- providers := goth.GetProviders()
-
- // loop over the used providers, if we already have a valid session for any provider (ie. user is already logged-in with a provider), then return that provider name
- for _, provider := range providers {
- p := provider.Name()
- session, _ := Store.Get(req, p+SessionName)
- value := session.Values[p]
- if _, ok := value.(string); ok {
- return p, nil
- }
- }
-
// try to get it from the url param "provider"
if p := req.URL.Query().Get("provider"); p != "" {
return p, nil
@@ -278,6 +265,17 @@ func getProviderName(req *http.Request) (string, error) {
return p, nil
}
+ // As a fallback, loop over the used providers, if we already have a valid session for any provider (ie. user has already begun authentication with a provider), then return that provider name
+ providers := goth.GetProviders()
+ session, _ := Store.Get(req, SessionName)
+ for _, provider := range providers {
+ p := provider.Name()
+ value := session.Values[p]
+ if _, ok := value.(string); ok {
+ return p, nil
+ }
+ }
+
// if not found then return an empty string with the corresponding error
return "", errors.New("you must select a provider")
}