diff options
author | Gusted <williamzijl7@hotmail.com> | 2022-07-11 11:48:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-11 13:48:43 +0200 |
commit | 8a7d1a3516c4479dae6824d5b0b041ed7dd5eb41 (patch) | |
tree | 13e4c46ea9dada9c336ebf7221faa18f4686c3f9 /models | |
parent | cb6c5f8193946cf65ba9b325a1989d72faaf2b86 (diff) | |
download | gitea-8a7d1a3516c4479dae6824d5b0b041ed7dd5eb41.tar.gz gitea-8a7d1a3516c4479dae6824d5b0b041ed7dd5eb41.zip |
Store read access in access for team repo's (#20275)
- Currently when a Team has read access to a organization's non-private
repository, their access won't be stored in the database. This caused
issue for code that rely on read access being stored. So from now-on if
we see that the repository is owned by a organization don't increase the
minMode to write permission.
- Resolves #20083
Diffstat (limited to 'models')
-rw-r--r-- | models/perm/access/access.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/models/perm/access/access.go b/models/perm/access/access.go index 7647519025..0e5e4ff2bb 100644 --- a/models/perm/access/access.go +++ b/models/perm/access/access.go @@ -86,7 +86,13 @@ func updateUserAccess(accessMap map[int64]*userAccess, user *user_model.User, mo // FIXME: do cross-comparison so reduce deletions and additions to the minimum? func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap map[int64]*userAccess) (err error) { minMode := perm.AccessModeRead - if !repo.IsPrivate { + if err := repo.GetOwner(ctx); err != nil { + return fmt.Errorf("GetOwner: %v", err) + } + + // If the repo isn't private and isn't owned by a organization, + // increase the minMode to Write. + if !repo.IsPrivate && !repo.Owner.IsOrganization() { minMode = perm.AccessModeWrite } |