aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjpicht2019-05-25 01:00:04 +0200
committerLauris BH2019-05-25 02:00:04 +0300
commit75e491c03ef3e75ffd0b0bcdb84bee058130a491 (patch)
tree837ab4385cf8c9342956b3183b6d58c00a0e140b
parent608f46e59c2333291319271eabed2907d41f6cda (diff)
Fix default for allowing new organization creation for new users (#7017) (#7034)
* FIX issue 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>
-rw-r--r--models/user.go3
-rw-r--r--models/user_test.go2
2 files changed, 3 insertions, 2 deletions
diff --git a/models/user.go b/models/user.go
index 484c358cf..bfbe9391b 100644
--- a/models/user.go
+++ b/models/user.go
@@ -832,10 +832,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 f0a8dbdd4..6af9752c9 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