From 474b94b59988a25c442961eee9744546115b2898 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Fri, 22 Aug 2025 15:30:28 -0400 Subject: [PATCH] rm legacy code --- gothic/provider.go | 3 -- gothic/provider_legacy.go | 66 --------------------------------------- gothic/provider_test.go | 3 -- 3 files changed, 72 deletions(-) delete mode 100644 gothic/provider_legacy.go diff --git a/gothic/provider.go b/gothic/provider.go index 60bc1eb1..f27d78dd 100644 --- a/gothic/provider.go +++ b/gothic/provider.go @@ -1,6 +1,3 @@ -//go:build go1.22 -// +build go1.22 - package gothic import ( diff --git a/gothic/provider_legacy.go b/gothic/provider_legacy.go deleted file mode 100644 index 74cfcffa..00000000 --- a/gothic/provider_legacy.go +++ /dev/null @@ -1,66 +0,0 @@ -//go:build !go1.22 -// +build !go1.22 - -package gothic - -import ( - "errors" - "net/http" - - "github.com/go-chi/chi/v5" - "github.com/gorilla/mux" - "github.com/markbates/goth" -) - -// GetProviderName is a function used to get the name of a provider -// for a given request. By default, this provider is fetched from -// the URL query string. If you provide it in a different way, -// assign your own function to this variable that returns the provider -// name for your request. -var GetProviderName = getProviderName - -func getProviderName(req *http.Request) (string, error) { - // try to get it from the url param "provider" - if p := req.URL.Query().Get("provider"); p != "" { - return p, nil - } - - // try to get it from the url param ":provider" - if p := req.URL.Query().Get(":provider"); p != "" { - return p, nil - } - - // try to get it from the context's value of "provider" key - if p, ok := mux.Vars(req)["provider"]; ok { - return p, nil - } - - // try to get it from the go-context's value of "provider" key - if p, ok := req.Context().Value("provider").(string); ok { - return p, nil - } - - // try to get it from the url param "provider", when req is routed through 'chi' - if p := chi.URLParam(req, "provider"); p != "" { - return p, nil - } - - // try to get it from the go-context's value of providerContextKey key - if p, ok := req.Context().Value(ProviderParamKey).(string); ok { - 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") -} diff --git a/gothic/provider_test.go b/gothic/provider_test.go index bf2b456f..f17db86e 100644 --- a/gothic/provider_test.go +++ b/gothic/provider_test.go @@ -1,6 +1,3 @@ -//go:build go1.22 -// +build go1.22 - package gothic_test import (