From 2eaf1d693ae08c0312dd1f977f81675f418f3770 Mon Sep 17 00:00:00 2001 From: ᴜɴᴋɴᴡᴏɴ Date: Tue, 6 Oct 2020 15:43:28 +0800 Subject: db: migrate access table to use GORM (#6371) --- internal/db/repo_branch.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'internal/db/repo_branch.go') 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 } -- cgit v1.2.3