summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorPeter Smit <peter@smitmail.eu>2015-02-12 14:25:07 +0200
committerPeter Smit <peter@smitmail.eu>2015-02-12 14:25:07 +0200
commit6c1ee384f1a45ed97f39b085209bcb79cafd9145 (patch)
tree0798c98ff2fa93324edae6cfcb539cf51fc4b7fd /routers
parent0a4cda0dd4d7c906668d9d2e283fbe9ebe2e1608 (diff)
parent0d158e569b0c19614b5e946849e8b7a8e4a75015 (diff)
downloadgitea-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 'routers')
-rw-r--r--routers/api/v1/repo.go2
-rw-r--r--routers/org/teams.go12
-rw-r--r--routers/repo/http.go12
-rw-r--r--routers/user/home.go4
4 files changed, 15 insertions, 15 deletions
diff --git a/routers/api/v1/repo.go b/routers/api/v1/repo.go
index 78c9f9a6a3..f5128e4746 100644
--- a/routers/api/v1/repo.go
+++ b/routers/api/v1/repo.go
@@ -255,7 +255,7 @@ func ListMyRepos(ctx *middleware.Context) {
return
}
- repos[i] = ToApiRepository(repo.Owner, repo, api.Permission{false, access >= models.WriteAccess, true})
+ repos[i] = ToApiRepository(repo.Owner, repo, api.Permission{false, access >= models.ACCESS_MODE_WRITE, true})
// FIXME: cache result to reduce DB query?
if repo.Owner.IsOrganization() && repo.Owner.IsOwnedBy(ctx.User.Id) {
diff --git a/routers/org/teams.go b/routers/org/teams.go
index f5f94be0f4..2fbb1480d1 100644
--- a/routers/org/teams.go
+++ b/routers/org/teams.go
@@ -168,11 +168,11 @@ func NewTeamPost(ctx *middleware.Context, form auth.CreateTeamForm) {
var auth models.AccessMode
switch form.Permission {
case "read":
- auth = models.ReadAccess
+ auth = models.ACCESS_MODE_READ
case "write":
- auth = models.WriteAccess
+ auth = models.ACCESS_MODE_WRITE
case "admin":
- auth = models.AdminAccess
+ auth = models.ACCESS_MODE_ADMIN
default:
ctx.Error(401)
return
@@ -249,11 +249,11 @@ func EditTeamPost(ctx *middleware.Context, form auth.CreateTeamForm) {
var auth models.AccessMode
switch form.Permission {
case "read":
- auth = models.ReadAccess
+ auth = models.ACCESS_MODE_READ
case "write":
- auth = models.WriteAccess
+ auth = models.ACCESS_MODE_WRITE
case "admin":
- auth = models.AdminAccess
+ auth = models.ACCESS_MODE_ADMIN
default:
ctx.Error(401)
return
diff --git a/routers/repo/http.go b/routers/repo/http.go
index c6742af3ec..a209c2b254 100644
--- a/routers/repo/http.go
+++ b/routers/repo/http.go
@@ -137,9 +137,9 @@ func Http(ctx *middleware.Context) {
}
if !isPublicPull {
- var tp = models.WriteAccess
+ var tp = models.ACCESS_MODE_WRITE
if isPull {
- tp = models.ReadAccess
+ tp = models.ACCESS_MODE_READ
}
has, err := models.HasAccess(authUser, repo, tp)
@@ -147,8 +147,8 @@ func Http(ctx *middleware.Context) {
ctx.Handle(401, "no basic auth and digit auth", nil)
return
} else if !has {
- if tp == models.ReadAccess {
- has, err = models.HasAccess(authUser, repo, models.WriteAccess)
+ if tp == models.ACCESS_MODE_READ {
+ has, err = models.HasAccess(authUser, repo, models.ACCESS_MODE_WRITE)
if err != nil || !has {
ctx.Handle(401, "no basic auth and digit auth", nil)
return
@@ -288,7 +288,7 @@ func serviceRpc(rpc string, hr handler) {
access := hasAccess(r, hr.Config, dir, rpc, true)
if access == false {
- renderNoAccess(w)
+ renderACCESS_MODE_NONE(w)
return
}
@@ -515,7 +515,7 @@ func renderNotFound(w http.ResponseWriter) {
w.Write([]byte("Not Found"))
}
-func renderNoAccess(w http.ResponseWriter) {
+func renderACCESS_MODE_NONE(w http.ResponseWriter) {
w.WriteHeader(http.StatusForbidden)
w.Write([]byte("Forbidden"))
}
diff --git a/routers/user/home.go b/routers/user/home.go
index 82325cb747..ce82ae772c 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -103,7 +103,7 @@ func Dashboard(ctx *middleware.Context) {
feeds := make([]*models.Action, 0, len(actions))
for _, act := range actions {
if act.IsPrivate {
- if has, _ := models.HasAccess(ctx.User, &models.Repository{Id: act.RepoId, IsPrivate: true}, models.ReadAccess); !has {
+ if has, _ := models.HasAccess(ctx.User, &models.Repository{Id: act.RepoId, IsPrivate: true}, models.ACCESS_MODE_READ); !has {
continue
}
}
@@ -211,7 +211,7 @@ func Profile(ctx *middleware.Context) {
continue
}
if has, _ := models.HasAccess(ctx.User, &models.Repository{Id: act.RepoId, IsPrivate: true},
- models.ReadAccess); !has {
+ models.ACCESS_MODE_READ); !has {
continue
}
}