|
|
@ -330,8 +330,8 @@ func (repo *Repository) getUnits(e Engine) (err error) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// CheckUnitUser check whether user could visit the unit of this repository
|
|
|
|
// CheckUnitUser check whether user could visit the unit of this repository
|
|
|
|
func (repo *Repository) CheckUnitUser(userID int64, unitType UnitType) bool { |
|
|
|
func (repo *Repository) CheckUnitUser(userID int64, isAdmin bool, unitType UnitType) bool { |
|
|
|
if err := repo.getUnitsByUserID(x, userID); err != nil { |
|
|
|
if err := repo.getUnitsByUserID(x, userID, isAdmin); err != nil { |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -344,11 +344,11 @@ func (repo *Repository) CheckUnitUser(userID int64, unitType UnitType) bool { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// LoadUnitsByUserID loads units according userID's permissions
|
|
|
|
// LoadUnitsByUserID loads units according userID's permissions
|
|
|
|
func (repo *Repository) LoadUnitsByUserID(userID int64) error { |
|
|
|
func (repo *Repository) LoadUnitsByUserID(userID int64, isAdmin bool) error { |
|
|
|
return repo.getUnitsByUserID(x, userID) |
|
|
|
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 { |
|
|
|
if repo.Units != nil { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
@ -358,7 +358,7 @@ func (repo *Repository) getUnitsByUserID(e Engine, userID int64) (err error) { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !repo.Owner.IsOrganization() || userID == 0 { |
|
|
|
if !repo.Owner.IsOrganization() || userID == 0 || isAdmin { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|