summaryrefslogtreecommitdiffstats
path: root/models/access.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-04-11 21:47:39 -0400
committerUnknown <joe2010xtmf@163.com>2014-04-11 21:47:39 -0400
commit33aa4f74380ab117673a1cc30bead3a7f2b3cb4b (patch)
treeac6c7c1ebebb86260545386c7ce923593e4d5046 /models/access.go
parentd6dac160dfcac068b31bda9316ddc3d4919e3288 (diff)
downloadgitea-33aa4f74380ab117673a1cc30bead3a7f2b3cb4b.tar.gz
gitea-33aa4f74380ab117673a1cc30bead3a7f2b3cb4b.zip
Support private repo
Diffstat (limited to 'models/access.go')
-rw-r--r--models/access.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/models/access.go b/models/access.go
index 2c0900151f..5bf93f1b1b 100644
--- a/models/access.go
+++ b/models/access.go
@@ -53,10 +53,17 @@ func UpdateAccessWithSession(sess *xorm.Session, access *Access) error {
// HasAccess returns true if someone can read or write to given repository.
func HasAccess(userName, repoName string, mode int) (bool, error) {
- return orm.Get(&Access{
- Id: 0,
+ access := &Access{
UserName: strings.ToLower(userName),
RepoName: strings.ToLower(repoName),
- Mode: mode,
- })
+ }
+ has, err := orm.Get(access)
+ if err != nil {
+ return false, err
+ } else if !has {
+ return false, nil
+ } else if mode > access.Mode {
+ return false, nil
+ }
+ return true, nil
}