Skip to content

Commit 747e74b

Browse files
GustedSysoev, Vladimir
Gusted
authored and
Sysoev, Vladimir
committed
Store read access in access for team repo's (go-gitea#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 go-gitea#20083
1 parent ba3d4a2 commit 747e74b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

models/perm/access/access.go

+7-1
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)