mirror of
https://github.com/go-gitea/gitea.git
synced 2025-06-20 21:18:00 +02:00
Work on admin
This commit is contained in:
@ -32,7 +32,6 @@ var (
|
||||
AppUrl string
|
||||
Domain string
|
||||
SecretKey string
|
||||
AdminName string
|
||||
Cfg *goconfig.ConfigFile
|
||||
MailService *Mailer
|
||||
)
|
||||
@ -174,7 +173,6 @@ func init() {
|
||||
AppUrl = Cfg.MustValue("server", "ROOT_URL")
|
||||
Domain = Cfg.MustValue("server", "DOMAIN")
|
||||
SecretKey = Cfg.MustValue("security", "SECRET_KEY")
|
||||
AdminName = strings.ToLower(Cfg.MustValue("admin", "NAME"))
|
||||
}
|
||||
|
||||
func NewServices() {
|
||||
|
@ -39,7 +39,7 @@ func SignOutRequire() martini.Handler {
|
||||
// AdminRequire requires user signed in as administor.
|
||||
func AdminRequire() martini.Handler {
|
||||
return func(ctx *Context) {
|
||||
if ctx.User.LowerName != base.AdminName && !ctx.User.IsAdmin {
|
||||
if !ctx.User.IsAdmin {
|
||||
ctx.Error(403)
|
||||
return
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import (
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/auth"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
)
|
||||
|
||||
@ -112,10 +111,7 @@ func InitContext() martini.Handler {
|
||||
ctx.Data["SignedUser"] = user
|
||||
ctx.Data["SignedUserId"] = user.Id
|
||||
ctx.Data["SignedUserName"] = user.LowerName
|
||||
|
||||
if ctx.User.IsAdmin || ctx.User.LowerName == base.AdminName {
|
||||
ctx.Data["IsAdmin"] = true
|
||||
}
|
||||
ctx.Data["IsAdmin"] = ctx.User.IsAdmin
|
||||
}
|
||||
|
||||
ctx.Data["PageStartTime"] = time.Now()
|
||||
|
Reference in New Issue
Block a user