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
This commit is contained in:
Peter Smit 2015-02-12 14:25:07 +02:00
commit 6c1ee384f1
10 changed files with 44 additions and 42 deletions

View file

@ -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"))
}