1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-04 08:17:24 -05:00

Fix panic when an invalid oauth2 name is passed (#20820)

This commit is contained in:
Balki 2022-08-17 18:25:28 +00:00 committed by GitHub
parent 7503cd35c2
commit c138e76c1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -512,10 +512,14 @@ func GetActiveOAuth2ProviderSources() ([]*Source, error) {
func GetActiveOAuth2SourceByName(name string) (*Source, error) { func GetActiveOAuth2SourceByName(name string) (*Source, error) {
authSource := new(Source) authSource := new(Source)
has, err := db.GetEngine(db.DefaultContext).Where("name = ? and type = ? and is_active = ?", name, OAuth2, true).Get(authSource) has, err := db.GetEngine(db.DefaultContext).Where("name = ? and type = ? and is_active = ?", name, OAuth2, true).Get(authSource)
if !has || err != nil { if err != nil {
return nil, err return nil, err
} }
if !has {
return nil, fmt.Errorf("oauth2 source not found, name: %q", name)
}
return authSource, nil return authSource, nil
} }