1
0
Fork 0
forked from forgejo/forgejo

Final round of db.DefaultContext refactor (#27587)

Last part of #27065
This commit is contained in:
JakobDev 2023-10-14 10:37:24 +02:00 committed by GitHub
parent ae419fa494
commit 76a85a4ce9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 250 additions and 242 deletions

View file

@ -4,6 +4,7 @@
package oauth2
import (
"context"
"encoding/gob"
"net/http"
"sync"
@ -26,7 +27,7 @@ const UsersStoreKey = "gitea-oauth2-sessions"
const ProviderHeaderKey = "gitea-oauth2-provider"
// Init initializes the oauth source
func Init() error {
func Init(ctx context.Context) error {
if err := InitSigningKey(); err != nil {
return err
}
@ -51,18 +52,18 @@ func Init() error {
// Unlock our mutex
gothRWMutex.Unlock()
return initOAuth2Sources()
return initOAuth2Sources(ctx)
}
// ResetOAuth2 clears existing OAuth2 providers and loads them from DB
func ResetOAuth2() error {
func ResetOAuth2(ctx context.Context) error {
ClearProviders()
return initOAuth2Sources()
return initOAuth2Sources(ctx)
}
// initOAuth2Sources is used to load and register all active OAuth2 providers
func initOAuth2Sources() error {
authSources, _ := auth.GetActiveOAuth2ProviderSources()
func initOAuth2Sources(ctx context.Context) error {
authSources, _ := auth.GetActiveOAuth2ProviderSources(ctx)
for _, source := range authSources {
oauth2Source, ok := source.Cfg.(*Source)
if !ok {