Skip to content

Commit

Permalink
Fix panic when an invalid oauth2 name is passed (#20820) (#20900)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeripath authored Aug 22, 2022
1 parent ec9b43b commit 37458bf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion models/auth/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 37458bf

Please sign in to comment.