This commit is contained in:
wxiaoguang
2024-04-19 11:09:07 +08:00
parent ba9b124c34
commit 3f27d4ea8e
13 changed files with 82 additions and 37 deletions
+2 -2
View File
@@ -218,7 +218,7 @@ func repoAssignment() func(ctx *context.APIContext) {
}
}
if !ctx.Repo.HasAccess() {
if !ctx.Repo.Permission.HasAnyUnitAccess() {
ctx.NotFound()
return
}
@@ -412,7 +412,7 @@ func reqRepoReader(unitType unit.Type) func(ctx *context.APIContext) {
// reqAnyRepoReader user should have any permission to read repository or permissions of site admin
func reqAnyRepoReader() func(ctx *context.APIContext) {
return func(ctx *context.APIContext) {
if !ctx.Repo.HasAccess() && !ctx.IsUserSiteAdmin() {
if !ctx.Repo.Permission.HasAnyUnitAccess() && !ctx.IsUserSiteAdmin() {
ctx.Error(http.StatusForbidden, "reqAnyRepoReader", "user should have any permission to read repository or permissions of site admin")
return
}
+1 -1
View File
@@ -585,7 +585,7 @@ func GetByID(ctx *context.APIContext) {
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", err)
return
} else if !permission.HasAccess() {
} else if !permission.HasAnyUnitAccess() {
ctx.NotFound()
return
}
+2 -2
View File
@@ -82,7 +82,7 @@ func ListPackages(ctx *context.Context) {
ctx.ServerError("GetUserRepoPermission", err)
return
}
repositoryAccessMap[pd.Repository.ID] = permission.HasAccess()
repositoryAccessMap[pd.Repository.ID] = permission.HasAnyUnitAccess()
}
hasPackages, err := packages_model.HasOwnerPackages(ctx, ctx.ContextUser.ID)
@@ -276,7 +276,7 @@ func ViewPackageVersion(ctx *context.Context) {
ctx.ServerError("GetUserRepoPermission", err)
return
}
hasRepositoryAccess = permission.HasAccess()
hasRepositoryAccess = permission.HasAnyUnitAccess()
}
ctx.Data["HasRepositoryAccess"] = hasRepositoryAccess