]> source.dussan.org Git - gitea.git/commitdiff
Fix deadlock when deleting team user (#13093)
authorzeripath <art27@cantab.net>
Sat, 10 Oct 2020 19:48:20 +0000 (20:48 +0100)
committerGitHub <noreply@github.com>
Sat, 10 Oct 2020 19:48:20 +0000 (22:48 +0300)
Backport #13092

`models.getUserRepoPermission(...)` calls `HasOrgVisible` which
uses `models.x` potentially outside of the transaction `e` provided
as an argument to `getUserRepoPermission`.

This PR switches to use `hasOrgVisible(e, ...)`.

Fix #12983

Signed-off-by: Andrew Thornton <art27@cantab.net>
models/repo_permission.go

index 2061f9770d71cb90a397d741c26f24b84d74931b..7768bb6257f6c22cdd14467e85018ffd2d2630eb 100644 (file)
@@ -178,7 +178,7 @@ func getUserRepoPermission(e Engine, repo *Repository, user *User) (perm Permiss
 
        // Prevent strangers from checking out public repo of private orginization
        // Allow user if they are collaborator of a repo within a private orginization but not a member of the orginization itself
-       if repo.Owner.IsOrganization() && !HasOrgVisible(repo.Owner, user) && !isCollaborator {
+       if repo.Owner.IsOrganization() && !hasOrgVisible(e, repo.Owner, user) && !isCollaborator {
                perm.AccessMode = AccessModeNone
                return
        }