aboutsummaryrefslogtreecommitdiffstats
path: root/models/auth/oauth2.go
diff options
context:
space:
mode:
authorBalki <189196+balki@users.noreply.github.com>2022-08-17 18:25:28 +0000
committerGitHub <noreply@github.com>2022-08-17 14:25:28 -0400
commitc138e76c1ce487beb6a34737a96d7c9239a50cd1 (patch)
tree92d926b706f418208bbb00f26aee3fca3fa4e1e2 /models/auth/oauth2.go
parent7503cd35c285741c6d9caf9797a5c953ae9dccf6 (diff)
downloadgitea-c138e76c1ce487beb6a34737a96d7c9239a50cd1.tar.gz
gitea-c138e76c1ce487beb6a34737a96d7c9239a50cd1.zip
Fix panic when an invalid oauth2 name is passed (#20820)
Diffstat (limited to 'models/auth/oauth2.go')
-rw-r--r--models/auth/oauth2.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/models/auth/oauth2.go b/models/auth/oauth2.go
index 5a58ec62b7..ad1d80e25a 100644
--- a/models/auth/oauth2.go
+++ b/models/auth/oauth2.go
@@ -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
}