summaryrefslogtreecommitdiffstats
path: root/modules/middleware/repo.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-05-05 19:58:13 -0400
committerUnknown <joe2010xtmf@163.com>2014-05-05 19:58:13 -0400
commit6e3dba2cc559275b5287673957ec855e61b4163a (patch)
treee7188a38aad06b17663aa48b03b523ab24329c58 /modules/middleware/repo.go
parentbbdfe2576966210cfffc830bfbe3731bcf653b3b (diff)
downloadgitea-6e3dba2cc559275b5287673957ec855e61b4163a.tar.gz
gitea-6e3dba2cc559275b5287673957ec855e61b4163a.zip
Clean repo code
Diffstat (limited to 'modules/middleware/repo.go')
-rw-r--r--modules/middleware/repo.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go
index f681ac139a..7d0cc97970 100644
--- a/modules/middleware/repo.go
+++ b/modules/middleware/repo.go
@@ -7,6 +7,7 @@ package middleware
import (
"errors"
"fmt"
+ "net/url"
"strings"
"github.com/go-martini/martini"
@@ -238,3 +239,17 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler {
ctx.Data["IsRepositoryWatching"] = ctx.Repo.IsWatching
}
}
+
+func RequireOwner() martini.Handler {
+ return func(ctx *Context) {
+ if !ctx.Repo.IsOwner {
+ if !ctx.IsSigned {
+ ctx.SetCookie("redirect_to", "/"+url.QueryEscape(ctx.Req.RequestURI))
+ ctx.Redirect("/user/login")
+ return
+ }
+ ctx.Handle(404, ctx.Req.RequestURI, nil)
+ return
+ }
+ }
+}