@@ -330,8 +330,8 @@ func (repo *Repository) getUnits(e Engine) (err error) {
330330}
331331
332332// CheckUnitUser check whether user could visit the unit of this repository
333- func (repo * Repository ) CheckUnitUser (userID int64 , unitType UnitType ) bool {
334- if err := repo .getUnitsByUserID (x , userID ); err != nil {
333+ func (repo * Repository ) CheckUnitUser (userID int64 , isAdmin bool , unitType UnitType ) bool {
334+ if err := repo .getUnitsByUserID (x , userID , isAdmin ); err != nil {
335335 return false
336336 }
337337
@@ -344,11 +344,11 @@ func (repo *Repository) CheckUnitUser(userID int64, unitType UnitType) bool {
344344}
345345
346346// LoadUnitsByUserID loads units according userID's permissions
347- func (repo * Repository ) LoadUnitsByUserID (userID int64 ) error {
348- return repo .getUnitsByUserID (x , userID )
347+ func (repo * Repository ) LoadUnitsByUserID (userID int64 , isAdmin bool ) error {
348+ return repo .getUnitsByUserID (x , userID , isAdmin )
349349}
350350
351- func (repo * Repository ) getUnitsByUserID (e Engine , userID int64 ) (err error ) {
351+ func (repo * Repository ) getUnitsByUserID (e Engine , userID int64 , isAdmin bool ) (err error ) {
352352 if repo .Units != nil {
353353 return nil
354354 }
@@ -358,7 +358,7 @@ func (repo *Repository) getUnitsByUserID(e Engine, userID int64) (err error) {
358358 return err
359359 }
360360
361- if ! repo .Owner .IsOrganization () || userID == 0 {
361+ if ! repo .Owner .IsOrganization () || userID == 0 || isAdmin {
362362 return nil
363363 }
364364
0 commit comments