-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c12a412
Merge pull request #1 from go-gitea/master
Schwobaland d41807e
restrict creating organizations based on right on user
9b5578c
revert bindata.go
e9ab23f
reverse vendor lib
3e950ca
revert goimports change
39f71b0
set AllowCreateOrganization default value to true
72d7f66
revert locale
677eb7f
added default value for AllowCreateOrganization
ffa4599
Merge changes from upstream
db6b318
fix typo in migration-comment
a27d29d
fix comment
2b5b351
add coments in migration
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// 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 ( | ||
"fmt" | ||
|
||
"github.com/go-xorm/xorm" | ||
) | ||
|
||
type UserV15 struct { | ||
AllowCreateOrganization bool | ||
} | ||
|
||
func (*UserV15) TableName() string { | ||
return "user" | ||
} | ||
|
||
func createAllowCreateOrganizationColumn(x *xorm.Engine) error { | ||
if err := x.Sync2(new(UserV15)); err != nil { | ||
return fmt.Errorf("Sync2: %v", err) | ||
} else if _, err = x.Where("type=0").Cols("allow_create_organization").Update(&UserV15{AllowCreateOrganization: true}); err != nil { | ||
return fmt.Errorf("set allow_create_organization: %v", err) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 `xorm:"DEFAULT true"` | ||
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 | ||
|
@@ -573,6 +579,7 @@ func CreateUser(u *User) (err error) { | |
u.Rands = GetUserSalt() | ||
u.Salt = GetUserSalt() | ||
u.EncodePasswd() | ||
u.AllowCreateOrganization = true | ||
u.MaxRepoCreation = -1 | ||
|
||
sess := x.NewSession() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
"... column ..."
?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.
fixed typo