Skip to content

Commit 2c6cb41

Browse files
author
Gusted
committed
Store read access in access for team repo's (go-gitea#20275)
- Backport go-gitea#20275 - Currently when a Team has read access to a organization's non-private repository, their access(in the `access` table) won't be stored in the database. This cause issues for code that rely on read access being stored, like retrieving all users who have read permission to that repository(even though this is confusing as this doesn't include all registered users). So from now-on if we see that the repository is owned by a organization don't increase the `minMode` to write permission. - Resolves go-gitea#20083
1 parent a92d247 commit 2c6cb41

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

models/perm/access/access.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,13 @@ func updateUserAccess(accessMap map[int64]*userAccess, user *user_model.User, mo
8686
// FIXME: do cross-comparison so reduce deletions and additions to the minimum?
8787
func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap map[int64]*userAccess) (err error) {
8888
minMode := perm.AccessModeRead
89-
if !repo.IsPrivate {
89+
if err := repo.GetOwner(ctx); err != nil {
90+
return fmt.Errorf("GetOwner: %v", err)
91+
}
92+
93+
// If the repo isn't private and isn't owned by a organization,
94+
// increase the minMode to Write.
95+
if !repo.IsPrivate && !repo.Owner.IsOrganization() {
9096
minMode = perm.AccessModeWrite
9197
}
9298

0 commit comments

Comments
 (0)