You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// try to get it from the context's value of "provider" key
277
-
ifp, ok:=mux.Vars(req)["provider"]; ok {
278
-
returnp, nil
279
-
}
280
-
281
-
// try to get it from the go-context's value of "provider" key
282
-
ifp, ok:=req.Context().Value("provider").(string); ok {
283
-
returnp, nil
284
-
}
285
-
286
-
// try to get it from the url param "provider", when req is routed through 'chi'
287
-
ifp:=chi.URLParam(req, "provider"); p!="" {
288
-
returnp, nil
289
-
}
290
-
291
-
// try to get it from the go-context's value of providerContextKey key
292
-
ifp, ok:=req.Context().Value(ProviderParamKey).(string); ok {
293
-
returnp, nil
294
-
}
295
-
296
-
// 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
297
-
providers:=goth.GetProviders()
298
-
session, _:=Store.Get(req, SessionName)
299
-
for_, provider:=rangeproviders {
300
-
p:=provider.Name()
301
-
value:=session.Values[p]
302
-
if_, ok:=value.(string); ok {
303
-
returnp, nil
304
-
}
305
-
}
306
-
307
-
// if not found then return an empty string with the corresponding error
308
-
return"", errors.New("you must select a provider")
309
-
}
310
-
311
254
// GetContextWithProvider returns a new request context containing the provider
// try to get it from the context's value of "provider" key
34
+
ifp, ok:=mux.Vars(req)["provider"]; ok {
35
+
returnp, nil
36
+
}
37
+
38
+
// try to get it from the go-context's value of "provider" key
39
+
ifp, ok:=req.Context().Value("provider").(string); ok {
40
+
returnp, nil
41
+
}
42
+
43
+
// try to get it from the url param "provider", when req is routed through 'chi'
44
+
ifp:=chi.URLParam(req, "provider"); p!="" {
45
+
returnp, nil
46
+
}
47
+
48
+
// try to get it from the route param for go >= 1.22
49
+
ifp:=req.PathValue("provider"); p!="" {
50
+
returnp, nil
51
+
}
52
+
53
+
// try to get it from the go-context's value of providerContextKey key
54
+
ifp, ok:=req.Context().Value(ProviderParamKey).(string); ok {
55
+
returnp, nil
56
+
}
57
+
58
+
// 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
59
+
providers:=goth.GetProviders()
60
+
session, _:=Store.Get(req, SessionName)
61
+
for_, provider:=rangeproviders {
62
+
p:=provider.Name()
63
+
value:=session.Values[p]
64
+
if_, ok:=value.(string); ok {
65
+
returnp, nil
66
+
}
67
+
}
68
+
69
+
// if not found then return an empty string with the corresponding error
70
+
return"", errors.New("you must select a provider")
// try to get it from the context's value of "provider" key
34
+
ifp, ok:=mux.Vars(req)["provider"]; ok {
35
+
returnp, nil
36
+
}
37
+
38
+
// try to get it from the go-context's value of "provider" key
39
+
ifp, ok:=req.Context().Value("provider").(string); ok {
40
+
returnp, nil
41
+
}
42
+
43
+
// try to get it from the url param "provider", when req is routed through 'chi'
44
+
ifp:=chi.URLParam(req, "provider"); p!="" {
45
+
returnp, nil
46
+
}
47
+
48
+
// try to get it from the go-context's value of providerContextKey key
49
+
ifp, ok:=req.Context().Value(ProviderParamKey).(string); ok {
50
+
returnp, nil
51
+
}
52
+
53
+
// 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
54
+
providers:=goth.GetProviders()
55
+
session, _:=Store.Get(req, SessionName)
56
+
for_, provider:=rangeproviders {
57
+
p:=provider.Name()
58
+
value:=session.Values[p]
59
+
if_, ok:=value.(string); ok {
60
+
returnp, nil
61
+
}
62
+
}
63
+
64
+
// if not found then return an empty string with the corresponding error
65
+
return"", errors.New("you must select a provider")
0 commit comments