summaryrefslogtreecommitdiffstats
path: root/modules/middleware/auth.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-20 07:50:26 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-20 07:50:26 -0400
commit9f9cd6bfc61d82ee0a3d31cee112be7975b8ca86 (patch)
tree1f50bb78b49e133425bc920ecfc9e25fe613823e /modules/middleware/auth.go
parent5cb2d3d2e233def07d6956af47dfc49acc45c7e6 (diff)
downloadgitea-9f9cd6bfc61d82ee0a3d31cee112be7975b8ca86.tar.gz
gitea-9f9cd6bfc61d82ee0a3d31cee112be7975b8ca86.zip
Work on admin
Diffstat (limited to 'modules/middleware/auth.go')
-rw-r--r--modules/middleware/auth.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/modules/middleware/auth.go b/modules/middleware/auth.go
index d45a21e988..b67f766bd7 100644
--- a/modules/middleware/auth.go
+++ b/modules/middleware/auth.go
@@ -20,7 +20,7 @@ func SignInRequire(redirect bool) martini.Handler {
return
} else if !ctx.User.IsActive && base.Service.RegisterEmailConfirm {
ctx.Data["Title"] = "Activate Your Account"
- ctx.Render.HTML(200, "user/active", ctx.Data)
+ ctx.HTML(200, "user/active")
return
}
}
@@ -31,6 +31,18 @@ func SignOutRequire() martini.Handler {
return func(ctx *Context) {
if ctx.IsSigned {
ctx.Redirect("/")
+ return
+ }
+ }
+}
+
+// AdminRequire requires user signed in as administor.
+func AdminRequire() martini.Handler {
+ return func(ctx *Context) {
+ if ctx.User.LowerName != base.AdminName && !ctx.User.IsAdmin {
+ ctx.Error(403)
+ return
}
+ ctx.Data["PageIsAdmin"] = true
}
}