Skip to content

Commit c138e76

Browse files
authored
Fix panic when an invalid oauth2 name is passed (#20820)
1 parent 7503cd3 commit c138e76

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

models/auth/oauth2.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,14 @@ func GetActiveOAuth2ProviderSources() ([]*Source, error) {
512512
func GetActiveOAuth2SourceByName(name string) (*Source, error) {
513513
authSource := new(Source)
514514
has, err := db.GetEngine(db.DefaultContext).Where("name = ? and type = ? and is_active = ?", name, OAuth2, true).Get(authSource)
515-
if !has || err != nil {
515+
if err != nil {
516516
return nil, err
517517
}
518518

519+
if !has {
520+
return nil, fmt.Errorf("oauth2 source not found, name: %q", name)
521+
}
522+
519523
return authSource, nil
520524
}
521525

0 commit comments

Comments
 (0)