From 8cd4c2242c6c0b3f53d9bd28b4b4e2cebfe46a04 Mon Sep 17 00:00:00 2001 From: jpicht Date: Fri, 24 May 2019 18:40:45 +0200 Subject: [PATCH] Fix default for allowing new organization creation for new users (#7017) Fixed #6542 When creating users DefaultAllowCreateOrganization was ignored. Signed-off-by: Julian Picht * fix TestCreateUser_Issue5882 Signed-off-by: Julian Picht --- models/user.go | 3 +-- models/user_test.go | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/models/user.go b/models/user.go index 90ca189ef0..7c7e81830e 100644 --- a/models/user.go +++ b/models/user.go @@ -849,10 +849,9 @@ func CreateUser(u *User) (err error) { return err } u.HashPassword(u.Passwd) - u.AllowCreateOrganization = setting.Service.DefaultAllowCreateOrganization + u.AllowCreateOrganization = setting.Service.DefaultAllowCreateOrganization && !setting.Admin.DisableRegularOrgCreation u.MaxRepoCreation = -1 u.Theme = setting.UI.DefaultTheme - u.AllowCreateOrganization = !setting.Admin.DisableRegularOrgCreation if _, err = sess.Insert(u); err != nil { return err diff --git a/models/user_test.go b/models/user_test.go index f0a8dbdd47..6af9752c9b 100644 --- a/models/user_test.go +++ b/models/user_test.go @@ -261,6 +261,8 @@ func TestCreateUser_Issue5882(t *testing.T) { {&User{Name: "GiteaBot2", Email: "GiteaBot2@gitea.io", Passwd: passwd, MustChangePassword: false}, true}, } + setting.Service.DefaultAllowCreateOrganization = true + for _, v := range tt { setting.Admin.DisableRegularOrgCreation = v.disableOrgCreation