1
0
Fork 0
forked from forgejo/forgejo

Refactor auth package (#17962)

This commit is contained in:
Lunny Xiao 2022-01-02 21:12:35 +08:00 committed by GitHub
parent e61b390d54
commit de8e3948a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
87 changed files with 2880 additions and 2770 deletions

View file

@ -9,7 +9,7 @@ import (
"net/http"
"sync"
"code.gitea.io/gitea/models/login"
"code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
@ -52,19 +52,19 @@ func Init() error {
// Unlock our mutex
gothRWMutex.Unlock()
return initOAuth2LoginSources()
return initOAuth2Sources()
}
// ResetOAuth2 clears existing OAuth2 providers and loads them from DB
func ResetOAuth2() error {
ClearProviders()
return initOAuth2LoginSources()
return initOAuth2Sources()
}
// initOAuth2LoginSources is used to load and register all active OAuth2 providers
func initOAuth2LoginSources() error {
loginSources, _ := login.GetActiveOAuth2ProviderLoginSources()
for _, source := range loginSources {
// initOAuth2Sources is used to load and register all active OAuth2 providers
func initOAuth2Sources() error {
authSources, _ := auth.GetActiveOAuth2ProviderSources()
for _, source := range authSources {
oauth2Source, ok := source.Cfg.(*Source)
if !ok {
continue