Skip to content

Commit

Permalink
Fix default for allowing new organization creation for new users (#7017)
Browse files Browse the repository at this point in the history
Fixed #6542

When creating users DefaultAllowCreateOrganization was ignored.

Signed-off-by: Julian Picht <[email protected]>

* fix TestCreateUser_Issue5882

Signed-off-by: Julian Picht <[email protected]>
  • Loading branch information
jpicht authored and lafriks committed May 24, 2019
1 parent 6ff9349 commit 8cd4c22
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions models/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ func TestCreateUser_Issue5882(t *testing.T) {
{&User{Name: "GiteaBot2", Email: "[email protected]", Passwd: passwd, MustChangePassword: false}, true},
}

setting.Service.DefaultAllowCreateOrganization = true

for _, v := range tt {
setting.Admin.DisableRegularOrgCreation = v.disableOrgCreation

Expand Down

0 comments on commit 8cd4c22

Please sign in to comment.