diff options
author | Peter Smit <peter@smitmail.eu> | 2015-02-12 14:25:07 +0200 |
---|---|---|
committer | Peter Smit <peter@smitmail.eu> | 2015-02-12 14:25:07 +0200 |
commit | 6c1ee384f1a45ed97f39b085209bcb79cafd9145 (patch) | |
tree | 0798c98ff2fa93324edae6cfcb539cf51fc4b7fd /models/access.go | |
parent | 0a4cda0dd4d7c906668d9d2e283fbe9ebe2e1608 (diff) | |
parent | 0d158e569b0c19614b5e946849e8b7a8e4a75015 (diff) | |
download | gitea-6c1ee384f1a45ed97f39b085209bcb79cafd9145.tar.gz gitea-6c1ee384f1a45ed97f39b085209bcb79cafd9145.zip |
Merge remote-tracking branch 'mine/access_refactor' into access_refactor
Conflicts:
cmd/serve.go
models/access.go
models/migrations/migrations.go
models/org.go
models/repo.go
models/user.go
modules/middleware/org.go
modules/middleware/repo.go
routers/api/v1/repo.go
routers/org/teams.go
routers/repo/http.go
routers/user/home.go
Diffstat (limited to 'models/access.go')
-rw-r--r-- | models/access.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/models/access.go b/models/access.go index d85f24cd06..174aca987f 100644 --- a/models/access.go +++ b/models/access.go @@ -7,15 +7,15 @@ package models type AccessMode int const ( - NoAccess AccessMode = iota - ReadAccess - WriteAccess - AdminAccess - OwnerAccess + ACCESS_MODE_NONE AccessMode = iota + ACCESS_MODE_READ + ACCESS_MODE_WRITE + ACCESS_MODE_ADMIN + ACCESS_MODE_OWNER ) func maxAccessMode(modes ...AccessMode) AccessMode { - max := NoAccess + max := ACCESS_MODE_NONE for _, mode := range modes { if mode > max { max = mode @@ -43,14 +43,14 @@ func HasAccess(u *User, r *Repository, testMode AccessMode) (bool, error) { // Return the Access a user has to a repository. Will return NoneAccess if the // user does not have access. User can be nil! func AccessLevel(u *User, r *Repository) (AccessMode, error) { - mode := NoAccess + mode := ACCESS_MODE_NONE if !r.IsPrivate { - mode = ReadAccess + mode = ACCESS_MODE_READ } if u != nil { if u.Id == r.OwnerId { - return OwnerAccess, nil + return ACCESS_MODE_OWNER, nil } a := &Access{UserID: u.Id, RepoID: r.Id} @@ -98,7 +98,7 @@ func (r *Repository) RecalcAccessSess() error { return err } for _, c := range collaborators { - accessMap[c.Id] = WriteAccess + accessMap[c.Id] = ACCESS_MODE_WRITE } if err := r.GetOwner(); err != nil { @@ -123,9 +123,9 @@ func (r *Repository) RecalcAccessSess() error { } } - minMode := ReadAccess + minMode := ACCESS_MODE_READ if !r.IsPrivate { - minMode = WriteAccess + minMode = ACCESS_MODE_WRITE } newAccesses := make([]Access, 0, len(accessMap)) |