mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 00:20:25 +08:00 
			
		
		
		
	Fix panic when an invalid oauth2 name is passed (#20820)
This commit is contained in:
		@@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user