summaryrefslogtreecommitdiffstats
path: root/models/access.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/access.go')
-rw-r--r--models/access.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/models/access.go b/models/access.go
index cf31fc137b..5238daba32 100644
--- a/models/access.go
+++ b/models/access.go
@@ -11,19 +11,20 @@ import (
"github.com/go-xorm/xorm"
)
-// Access types.
+type AccessType int
+
const (
- AU_READABLE = iota + 1
- AU_WRITABLE
+ READABLE AccessType = iota + 1
+ WRITABLE
)
// Access represents the accessibility of user to repository.
type Access struct {
Id int64
- UserName string `xorm:"unique(s)"`
- RepoName string `xorm:"unique(s)"` // <user name>/<repo name>
- Mode int `xorm:"unique(s)"`
- Created time.Time `xorm:"created"`
+ UserName string `xorm:"unique(s)"`
+ RepoName string `xorm:"unique(s)"` // <user name>/<repo name>
+ Mode AccessType `xorm:"unique(s)"`
+ Created time.Time `xorm:"created"`
}
// AddAccess adds new access record.
@@ -59,7 +60,7 @@ func UpdateAccessWithSession(sess *xorm.Session, access *Access) error {
// HasAccess returns true if someone can read or write to given repository.
// The repoName should be in format <username>/<reponame>.
-func HasAccess(uname, repoName string, mode int) (bool, error) {
+func HasAccess(uname, repoName string, mode AccessType) (bool, error) {
if len(repoName) == 0 {
return false, nil
}