summaryrefslogtreecommitdiffstats
path: root/models/access.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/access.go')
-rw-r--r--models/access.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/models/access.go b/models/access.go
index 49a8838ea6..98ead19a0b 100644
--- a/models/access.go
+++ b/models/access.go
@@ -59,21 +59,21 @@ type Access struct {
Mode AccessMode
}
-func accessLevel(e Engine, user *User, repo *Repository) (AccessMode, error) {
+func accessLevel(e Engine, userID int64, repo *Repository) (AccessMode, error) {
mode := AccessModeNone
if !repo.IsPrivate {
mode = AccessModeRead
}
- if user == nil {
+ if userID == 0 {
return mode, nil
}
- if user.ID == repo.OwnerID {
+ if userID == repo.OwnerID {
return AccessModeOwner, nil
}
- a := &Access{UserID: user.ID, RepoID: repo.ID}
+ a := &Access{UserID: userID, RepoID: repo.ID}
if has, err := e.Get(a); !has || err != nil {
return mode, err
}
@@ -81,19 +81,19 @@ func accessLevel(e Engine, user *User, repo *Repository) (AccessMode, error) {
}
// AccessLevel returns the Access a user has to a repository. Will return NoneAccess if the
-// user does not have access. User can be nil!
-func AccessLevel(user *User, repo *Repository) (AccessMode, error) {
- return accessLevel(x, user, repo)
+// user does not have access.
+func AccessLevel(userID int64, repo *Repository) (AccessMode, error) {
+ return accessLevel(x, userID, repo)
}
-func hasAccess(e Engine, user *User, repo *Repository, testMode AccessMode) (bool, error) {
- mode, err := accessLevel(e, user, repo)
+func hasAccess(e Engine, userID int64, repo *Repository, testMode AccessMode) (bool, error) {
+ mode, err := accessLevel(e, userID, repo)
return testMode <= mode, err
}
-// HasAccess returns true if someone has the request access level. User can be nil!
-func HasAccess(user *User, repo *Repository, testMode AccessMode) (bool, error) {
- return hasAccess(x, user, repo, testMode)
+// HasAccess returns true if user has access to repo
+func HasAccess(userID int64, repo *Repository, testMode AccessMode) (bool, error) {
+ return hasAccess(x, userID, repo, testMode)
}
type repoAccess struct {