1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-23 10:48:37 +00:00

restricted users only see repos in orgs witch there team was assigned to

This commit is contained in:
m.huber
2023-11-13 20:06:14 +01:00
parent 0c655c4ff0
commit 5bc3b8655c
2 changed files with 7 additions and 6 deletions

View File

@@ -652,12 +652,12 @@ func AccessibleRepositoryCondition(user *user_model.User, unitType unit.Type) bu
userOrgTeamUnitRepoCond("`repository`.id", user.ID, unitType), userOrgTeamUnitRepoCond("`repository`.id", user.ID, unitType),
) )
} }
cond = cond.Or( // 4. Repositories that we directly own
// 4. Repositories that we directly own cond = cond.Or(builder.Eq{"`repository`.owner_id": user.ID})
builder.Eq{"`repository`.owner_id": user.ID}, if !user.IsRestricted {
// 5. Be able to see all public repos in private organizations that we are an org_user of // 5. Be able to see all public repos in private organizations that we are an org_user of
userOrgPublicRepoCond(user.ID), cond = cond.Or(userOrgPublicRepoCond(user.ID))
) }
} }
return cond return cond

View File

@@ -160,7 +160,8 @@ func BuildCanSeeUserCondition(actor *User) builder.Cond {
// or private users who do follow them // or private users who do follow them
cond = cond.Or(builder.Eq{ cond = cond.Or(builder.Eq{
"`user`.visibility": structs.VisibleTypePrivate, "`user`.visibility": structs.VisibleTypePrivate,
"`user`.id": builder.Select("follow.user_id").From("follow").Where(builder.Eq{"follow.follow_id": actor.ID})}) "`user`.id": builder.Select("follow.user_id").From("follow").Where(builder.Eq{"follow.follow_id": actor.ID}),
})
} }
// Don't forget about self // Don't forget about self
return cond.Or(builder.Eq{"`user`.id": actor.ID}) return cond.Or(builder.Eq{"`user`.id": actor.ID})