diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2018-11-28 19:26:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-28 19:26:14 +0800 |
commit | eabbddcd98717ef20d8475e819f403c50f4a9787 (patch) | |
tree | efc525e7ec60d56d3bec72019febfa088a128b89 /models/user.go | |
parent | 0222623be9fa4a56d870213f77b92139cefc2518 (diff) | |
download | gitea-eabbddcd98717ef20d8475e819f403c50f4a9787.tar.gz gitea-eabbddcd98717ef20d8475e819f403c50f4a9787.zip |
Restrict permission check on repositories and fix some problems (#5314)
* fix units permission problems
* fix some bugs and merge LoadUnits to repoAssignment
* refactor permission struct and add some copyright heads
* remove unused codes
* fix routes units check
* improve permission check
* add unit tests for permission
* fix typo
* fix tests
* fix some routes
* fix api permission check
* improve permission check
* fix some permission check
* fix tests
* fix tests
* improve some permission check
* fix some permission check
* refactor AccessLevel
* fix bug
* fix tests
* fix tests
* fix tests
* fix AccessLevel
* rename CanAccess
* fix tests
* fix comment
* fix bug
* add missing unit for test repos
* fix bug
* rename some functions
* fix routes check
Diffstat (limited to 'models/user.go')
-rw-r--r-- | models/user.go | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/models/user.go b/models/user.go index 9becee7760..8f1b170b0d 100644 --- a/models/user.go +++ b/models/user.go @@ -496,24 +496,6 @@ func (u *User) DeleteAvatar() error { return nil } -// IsAdminOfRepo returns true if user has admin or higher access of repository. -func (u *User) IsAdminOfRepo(repo *Repository) bool { - has, err := HasAccess(u.ID, repo, AccessModeAdmin) - if err != nil { - log.Error(3, "HasAccess: %v", err) - } - return has -} - -// IsWriterOfRepo returns true if user has write access to given repository. -func (u *User) IsWriterOfRepo(repo *Repository) bool { - has, err := HasAccess(u.ID, repo, AccessModeWrite) - if err != nil { - log.Error(3, "HasAccess: %v", err) - } - return has -} - // IsOrganization returns true if user is actually a organization. func (u *User) IsOrganization() bool { return u.Type == UserTypeOrganization @@ -1170,17 +1152,6 @@ func GetUserByID(id int64) (*User, error) { return getUserByID(x, id) } -// GetUserIfHasWriteAccess returns the user with write access of repository by given ID. -func GetUserIfHasWriteAccess(repo *Repository, userID int64) (*User, error) { - has, err := HasAccess(userID, repo, AccessModeWrite) - if err != nil { - return nil, err - } else if !has { - return nil, ErrUserNotExist{userID, "", 0} - } - return GetUserByID(userID) -} - // GetUserByName returns user by given name. func GetUserByName(name string) (*User, error) { return getUserByName(x, name) |