mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-03 21:08:25 +00:00 
			
		
		
		
	Fix default for allowing new organization creation for new users (#7017)
Fixed #6542 When creating users DefaultAllowCreateOrganization was ignored. Signed-off-by: Julian Picht <julian.picht@gmail.com> * fix TestCreateUser_Issue5882 Signed-off-by: Julian Picht <julian.picht@gmail.com>
This commit is contained in:
		@@ -849,10 +849,9 @@ func CreateUser(u *User) (err error) {
 | 
				
			|||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	u.HashPassword(u.Passwd)
 | 
						u.HashPassword(u.Passwd)
 | 
				
			||||||
	u.AllowCreateOrganization = setting.Service.DefaultAllowCreateOrganization
 | 
						u.AllowCreateOrganization = setting.Service.DefaultAllowCreateOrganization && !setting.Admin.DisableRegularOrgCreation
 | 
				
			||||||
	u.MaxRepoCreation = -1
 | 
						u.MaxRepoCreation = -1
 | 
				
			||||||
	u.Theme = setting.UI.DefaultTheme
 | 
						u.Theme = setting.UI.DefaultTheme
 | 
				
			||||||
	u.AllowCreateOrganization = !setting.Admin.DisableRegularOrgCreation
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if _, err = sess.Insert(u); err != nil {
 | 
						if _, err = sess.Insert(u); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -261,6 +261,8 @@ func TestCreateUser_Issue5882(t *testing.T) {
 | 
				
			|||||||
		{&User{Name: "GiteaBot2", Email: "GiteaBot2@gitea.io", Passwd: passwd, MustChangePassword: false}, true},
 | 
							{&User{Name: "GiteaBot2", Email: "GiteaBot2@gitea.io", Passwd: passwd, MustChangePassword: false}, true},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						setting.Service.DefaultAllowCreateOrganization = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, v := range tt {
 | 
						for _, v := range tt {
 | 
				
			||||||
		setting.Admin.DisableRegularOrgCreation = v.disableOrgCreation
 | 
							setting.Admin.DisableRegularOrgCreation = v.disableOrgCreation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user