-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restrict creating organisations by user #193
Changes from 2 commits
c12a412
d41807e
9b5578c
e9ab23f
3e950ca
39f71b0
72d7f66
677eb7f
ffa4599
db6b318
a27d29d
2b5b351
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ import ( | |
"github.com/Unknwon/com" | ||
"github.com/go-xorm/xorm" | ||
gouuid "github.com/satori/go.uuid" | ||
"gopkg.in/ini.v1" | ||
ini "gopkg.in/ini.v1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this isn't needed for your patch please avoid the change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As long as it's done in a separate commit it's OK. It's an goimports correction. |
||
|
||
"code.gitea.io/gitea/modules/base" | ||
"code.gitea.io/gitea/modules/log" | ||
|
@@ -72,8 +72,10 @@ var migrations = []Migration{ | |
|
||
// v13 -> v14:v0.9.87 | ||
NewMigration("set comment updated with created", setCommentUpdatedWithCreated), | ||
|
||
// v14 | ||
NewMigration("create user column diff view style", createUserColumnDiffViewStyle), | ||
// v15 | ||
NewMigration("create user colum allow create organization", createAllowCreateOrganizationColumn), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed typo |
||
} | ||
|
||
// Migrate database to current version | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2016 Gitea. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package migrations | ||
|
||
import "github.com/go-xorm/xorm" | ||
|
||
type UserV15 struct { | ||
AllowCreateOrganization bool | ||
} | ||
|
||
func (*UserV15) TableName() string { | ||
return "user" | ||
} | ||
|
||
func createAllowCreateOrganizationColumn(x *xorm.Engine) error { | ||
return x.Sync2(new(UserV15)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the default value set for existing users upon migration ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the default have to be true |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,11 +84,12 @@ type User struct { | |
MaxRepoCreation int `xorm:"NOT NULL DEFAULT -1"` | ||
|
||
// Permissions | ||
IsActive bool // Activate primary email | ||
IsAdmin bool | ||
AllowGitHook bool | ||
AllowImportLocal bool // Allow migrate repository by local path | ||
ProhibitLogin bool | ||
IsActive bool // Activate primary email | ||
IsAdmin bool | ||
AllowGitHook bool | ||
AllowImportLocal bool // Allow migrate repository by local path | ||
AllowCreateOrganization bool | ||
ProhibitLogin bool | ||
|
||
// Avatar | ||
Avatar string `xorm:"VARCHAR(2048) NOT NULL"` | ||
|
@@ -185,6 +186,11 @@ func (u *User) CanCreateRepo() bool { | |
return u.NumRepos < u.MaxRepoCreation | ||
} | ||
|
||
// CanCreateOrg returns true if user can create organisation. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed typo |
||
func (u *User) CanCreateOrganization() bool { | ||
return u.IsAdmin || u.AllowCreateOrganization | ||
} | ||
|
||
// CanEditGitHook returns true if user can edit Git hooks. | ||
func (u *User) CanEditGitHook() bool { | ||
return u.IsAdmin || u.AllowGitHook | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,12 @@ | |
package auth | ||
|
||
import ( | ||
"gopkg.in/macaron.v1" | ||
macaron "gopkg.in/macaron.v1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this isn't needed for your patch please avoid the change |
||
|
||
"github.com/go-macaron/binding" | ||
) | ||
|
||
type AdminCrateUserForm struct { | ||
type AdminCreateUserForm struct { | ||
LoginType string `binding:"Required"` | ||
LoginName string | ||
UserName string `binding:"Required;AlphaDashDot;MaxSize(35)"` | ||
|
@@ -19,24 +19,25 @@ type AdminCrateUserForm struct { | |
SendNotify bool | ||
} | ||
|
||
func (f *AdminCrateUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { | ||
func (f *AdminCreateUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { | ||
return validate(errs, ctx.Data, f, ctx.Locale) | ||
} | ||
|
||
type AdminEditUserForm struct { | ||
LoginType string `binding:"Required"` | ||
LoginName string | ||
FullName string `binding:"MaxSize(100)"` | ||
Email string `binding:"Required;Email;MaxSize(254)"` | ||
Password string `binding:"MaxSize(255)"` | ||
Website string `binding:"MaxSize(50)"` | ||
Location string `binding:"MaxSize(50)"` | ||
MaxRepoCreation int | ||
Active bool | ||
Admin bool | ||
AllowGitHook bool | ||
AllowImportLocal bool | ||
ProhibitLogin bool | ||
LoginType string `binding:"Required"` | ||
LoginName string | ||
FullName string `binding:"MaxSize(100)"` | ||
Email string `binding:"Required;Email;MaxSize(254)"` | ||
Password string `binding:"MaxSize(255)"` | ||
Website string `binding:"MaxSize(50)"` | ||
Location string `binding:"MaxSize(50)"` | ||
MaxRepoCreation int | ||
Active bool | ||
Admin bool | ||
AllowGitHook bool | ||
AllowImportLocal bool | ||
AllowCreateOrganization bool | ||
ProhibitLogin bool | ||
} | ||
|
||
func (f *AdminEditUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're supposed to only modify the english localization, whereas other languages are delegated to an external service. Please @lunny, @bkcsoft, @tboerger correct me if I'm wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't find the translation service for gitea. There is only Crowdin for gogs and an empty project for gitea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to use an external service again but it's not enabled yet