Skip to content

Commit

Permalink
Fix panic when an invalid oauth2 name is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
balki authored and balki committed Aug 17, 2022
1 parent a4e91c4 commit 9c4da36
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 9c4da36

Please sign in to comment.