aboutsummaryrefslogtreecommitdiff
path: root/internal/db/repo.go
diff options
context:
space:
mode:
authorJoe Chen <jc@unknwon.io>2023-02-02 21:14:27 +0800
committerGitHub <noreply@github.com>2023-02-02 21:14:27 +0800
commit614382fec0ba05149785539ab93560d4d42c194d (patch)
tree50037ddd412606cfadb278a9c9ea7c4a1eb3d4cc /internal/db/repo.go
parent9df10cb8cc84fbeba9eb603c458078f132a6c201 (diff)
refactor(db): migrate methods off `user.go` (#7329)
Diffstat (limited to 'internal/db/repo.go')
-rw-r--r--internal/db/repo.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/internal/db/repo.go b/internal/db/repo.go
index 896c39b8..4d1c3e82 100644
--- a/internal/db/repo.go
+++ b/internal/db/repo.go
@@ -524,7 +524,20 @@ func (repo *Repository) GetAssignees() (_ []*User, err error) {
// GetAssigneeByID returns the user that has write access of repository by given ID.
func (repo *Repository) GetAssigneeByID(userID int64) (*User, error) {
- return GetAssigneeByID(repo, userID)
+ ctx := context.TODO()
+ if !Perms.Authorize(
+ ctx,
+ userID,
+ repo.ID,
+ AccessModeRead,
+ AccessModeOptions{
+ OwnerID: repo.OwnerID,
+ Private: repo.IsPrivate,
+ },
+ ) {
+ return nil, ErrUserNotExist{args: errutil.Args{"userID": userID}}
+ }
+ return Users.GetByID(ctx, userID)
}
// GetWriters returns all users that have write access to the repository.