summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-05-19 08:59:26 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-05-19 08:59:26 +0800
commit6362462da8958980385aad7c8df503d90e13380d (patch)
tree04b10fe28c10b1de457677ae35555cb91050b235 /models
parent25d6e2a6601f6a8ffd812db35da7692a82044a7f (diff)
downloadgitea-6362462da8958980385aad7c8df503d90e13380d.tar.gz
gitea-6362462da8958980385aad7c8df503d90e13380d.zip
fix admin lost permission caused by #947
Diffstat (limited to 'models')
-rw-r--r--models/repo.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/models/repo.go b/models/repo.go
index e1b7014551..0c755241ce 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -330,8 +330,8 @@ func (repo *Repository) getUnits(e Engine) (err error) {
}
// CheckUnitUser check whether user could visit the unit of this repository
-func (repo *Repository) CheckUnitUser(userID int64, unitType UnitType) bool {
- if err := repo.getUnitsByUserID(x, userID); err != nil {
+func (repo *Repository) CheckUnitUser(userID int64, isAdmin bool, unitType UnitType) bool {
+ if err := repo.getUnitsByUserID(x, userID, isAdmin); err != nil {
return false
}
@@ -344,11 +344,11 @@ func (repo *Repository) CheckUnitUser(userID int64, unitType UnitType) bool {
}
// LoadUnitsByUserID loads units according userID's permissions
-func (repo *Repository) LoadUnitsByUserID(userID int64) error {
- return repo.getUnitsByUserID(x, userID)
+func (repo *Repository) LoadUnitsByUserID(userID int64, isAdmin bool) error {
+ return repo.getUnitsByUserID(x, userID, isAdmin)
}
-func (repo *Repository) getUnitsByUserID(e Engine, userID int64) (err error) {
+func (repo *Repository) getUnitsByUserID(e Engine, userID int64, isAdmin bool) (err error) {
if repo.Units != nil {
return nil
}
@@ -358,7 +358,7 @@ func (repo *Repository) getUnitsByUserID(e Engine, userID int64) (err error) {
return err
}
- if !repo.Owner.IsOrganization() || userID == 0 {
+ if !repo.Owner.IsOrganization() || userID == 0 || isAdmin {
return nil
}