aboutsummaryrefslogtreecommitdiff
path: root/internal/db/user.go
diff options
context:
space:
mode:
authorJoe Chen <jc@unknwon.io>2022-06-08 19:26:20 +0800
committerGitHub <noreply@github.com>2022-06-08 19:26:20 +0800
commit7229dd893f15ae30d20332706e40d8a87e0f94b0 (patch)
tree1e60a6751834efc257a4ab31c69b55bae3959e02 /internal/db/user.go
parent0918d8758b7470c5e1f64a62c2e48e4168993394 (diff)
db: use `context` and go-mockgen for `PermsStore` (#7033)
Diffstat (limited to 'internal/db/user.go')
-rw-r--r--internal/db/user.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/internal/db/user.go b/internal/db/user.go
index d5d2d60f..c6bee120 100644
--- a/internal/db/user.go
+++ b/internal/db/user.go
@@ -6,6 +6,7 @@ package db
import (
"bytes"
+ "context"
"crypto/sha256"
"crypto/subtle"
"encoding/hex"
@@ -369,7 +370,7 @@ func (u *User) DeleteAvatar() error {
// IsAdminOfRepo returns true if user has admin or higher access of repository.
func (u *User) IsAdminOfRepo(repo *Repository) bool {
- return Perms.Authorize(u.ID, repo.ID, AccessModeAdmin,
+ return Perms.Authorize(context.TODO(), u.ID, repo.ID, AccessModeAdmin,
AccessModeOptions{
OwnerID: repo.OwnerID,
Private: repo.IsPrivate,
@@ -379,7 +380,7 @@ func (u *User) IsAdminOfRepo(repo *Repository) bool {
// IsWriterOfRepo returns true if user has write access to given repository.
func (u *User) IsWriterOfRepo(repo *Repository) bool {
- return Perms.Authorize(u.ID, repo.ID, AccessModeWrite,
+ return Perms.Authorize(context.TODO(), u.ID, repo.ID, AccessModeWrite,
AccessModeOptions{
OwnerID: repo.OwnerID,
Private: repo.IsPrivate,
@@ -941,7 +942,7 @@ func GetUserByID(id int64) (*User, error) {
// GetAssigneeByID returns the user with read access of repository by given ID.
func GetAssigneeByID(repo *Repository, userID int64) (*User, error) {
- if !Perms.Authorize(userID, repo.ID, AccessModeRead,
+ if !Perms.Authorize(context.TODO(), userID, repo.ID, AccessModeRead,
AccessModeOptions{
OwnerID: repo.OwnerID,
Private: repo.IsPrivate,