diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-10-06 15:43:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-06 15:43:28 +0800 |
commit | 2eaf1d693ae08c0312dd1f977f81675f418f3770 (patch) | |
tree | b42a26180e813918a05a676bd18e13a3a1bb73ec /internal/db/repo_branch.go | |
parent | a92d818aa35583594a6b3098f4e1e1f4edec17dd (diff) |
db: migrate access table to use GORM (#6371)
Diffstat (limited to 'internal/db/repo_branch.go')
-rw-r--r-- | internal/db/repo_branch.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/internal/db/repo_branch.go b/internal/db/repo_branch.go index ceb99231..3b7f9137 100644 --- a/internal/db/repo_branch.go +++ b/internal/db/repo_branch.go @@ -175,10 +175,12 @@ func UpdateOrgProtectBranch(repo *Repository, protectBranch *ProtectBranch, whit userIDs := tool.StringsToInt64s(strings.Split(whitelistUserIDs, ",")) validUserIDs = make([]int64, 0, len(userIDs)) for _, userID := range userIDs { - has, err := HasAccess(userID, repo, AccessModeWrite) - if err != nil { - return fmt.Errorf("HasAccess [user_id: %d, repo_id: %d]: %v", userID, protectBranch.RepoID, err) - } else if !has { + if !Perms.Authorize(userID, repo.ID, AccessModeWrite, + AccessModeOptions{ + OwnerID: repo.OwnerID, + Private: repo.IsPrivate, + }, + ) { continue // Drop invalid user ID } |