Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-27 20:26:09 +01:00

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

This commit is contained in:
zeripath 2022-08-22 04:23:48 +01:00 committed by GitHub
parent ec9b43ba16
commit 37458bffbf
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) {
authSource := new(Source)
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
}
if !has {
return nil, fmt.Errorf("oauth2 source not found, name: %q", name)
}
return authSource, nil
}